I would like to read an Excel sheet into Pandas DataFrame. However, there are merged Excel cells as well as Null rows (full/partial NaN
filled), as shown below. To clarify, John H. has made an order to purchase all the albums from "The Bodyguard" to "Red Pill Blues".
When I read this Excel sheet into a Pandas DataFrame, the Excel data does not get transferred correctly. Pandas considers a merged cell as one cell. The DataFrame looks like the following: (Note: Values in () are the desired values that I would like to have there)
Please note that the last row does not contain merged cells; it only carries a value for Artist
column.
EDIT: I did try the following to forward-fill in the NaN values:(Pandas: Reading Excel with merged cells)
df.index = pd.Series(df.index).fillna(method='ffill')
However, the NaN
values remain. What strategy or method could I use to populate the DataFrame correctly? Is there a Pandas method of unmerging the cells and duplicating the corresponding contents?