Pandas: Reading Excel with merged cells
You could use the Series.fillna method to forword-fill in the NaN values:
df.index = pd.Series(df.index).fillna(method='ffill')
For example,
In [42]: dfOut[42]: Sample CD4 CD8Day 1 8311 17.30 6.44NaN 8312 13.60 3.50NaN 8321 19.80 5.88NaN 8322 13.50 4.09Day 2 8311 16.00 4.92NaN 8312 5.67 2.28NaN 8321 13.00 4.34NaN 8322 10.60 1.95[8 rows x 3 columns]In [43]: df.index = pd.Series(df.index).fillna(method='ffill')In [44]: dfOut[44]: Sample CD4 CD8Day 1 8311 17.30 6.44Day 1 8312 13.60 3.50Day 1 8321 19.80 5.88Day 1 8322 13.50 4.09Day 2 8311 16.00 4.92Day 2 8312 5.67 2.28Day 2 8321 13.00 4.34Day 2 8322 10.60 1.95[8 rows x 3 columns]