Home > Mobile >  How do i properly format the excel worksheet in python?
How do i properly format the excel worksheet in python?

Time:06-01

I have an Excel Workbook that looks like this: enter image description here when I try to import this sheet into python using the following code:

xls = pd.ExcelFile(path)
xls.sheet_names
ac_char = pd.read_excel(path, sheet_name = "AC characteristics")

the output of the above code is: enter image description here How do I eliminate those NaNs and just display the main columns that have the data?

CodePudding user response:

You could skip the first two rows using skiprows and first column using usecols:

ac_char = pd.read_excel(path, sheet_name="AC characteristics", skiprows=[0,1], usecols=[1:])

See also: enter image description here

  • Related