I have a Excel file with a index that is merged over several rows in Excel, and when I load it in pandas, it reads the first row as the index label, and the rest (the merged cells) is filled with NaNs. How can I loop over the index so that it fills the NaNs with the corresponding index?
EDIT: Image of excel removed by request. I don't have any specific code, but I can write an example.
import pandas as pd
df = pd.read_excel('myexcelfile.xlsx', header=1)
df.head()
Index-header Month
0 Index1 1
1 NaN 2
2 NaN 3
3 NaN 4
4 NaN 5
5 Index2 1
6 NaN 2
...