3

How to read excels merged header cells as shown below in Pandas such that Frequency header can show up like Frequency_1, Frequency_2, Frequency_3

enter image description here

I am currently reading it as

data = (pandas.read_excel(excelfilename, sheetname, header)).values

while data read is correct but I end-up with header as

['Frequency' nan nan]

Vic
  • 1,985
  • 1
  • 19
  • 30

1 Answers1

0

if you want setting the header to the Frequency_1, Frequency_2, Frequency_3, you can setting the header by hand.

data = (pandas.read_excel(excelfilename, sheetname, header=[Frequency_1, Frequency_2, Frequency_3]))

https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_excel.html

if you want fill the header with new value, please used this way:

>>> values = {'A': 0, 'B': 1, 'C': 2, 'D': 3}
>>> df.fillna(value=values)
    A   B   C   D
0   0.0 2.0 2.0 0
1   3.0 4.0 2.0 1
2   0.0 1.0 2.0 5
3   0.0 3.0 2.0 4

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.fillna.html

youDaily
  • 1,372
  • 13
  • 21