I have a data set like the following. We only have data for the last day of a month I am trying to interpolate rest of it, is it the right way of doing it?
Date Australia China
2011-01-01 NaN NaN
2011-01-02 NaN NaN
- - -
- - -
2011-01-31 4.75 5.81
2011-02-01 NaN NaN
2011-02-02 NaN NaN
- - -
- - -
2011-02-28 4.75 5.81
2011-03-01 NaN NaN
2011-03-02 NaN NaN
- - -
- - -
2011-03-31 4.75 6.06
2011-04-01 NaN NaN
2011-04-02 NaN NaN
- - -
- - -
2011-04-30 4.75 6.06
For interpolate this dataframe to find missing NaN values I am using the following code
import pandas as pd
df = pd.read_csv("data.csv", index_col="Date")
df.index = pd.DatetimeIndex(df.index)
df.interpolate(method='linear', axis=0).ffill().bfill()
But I am getting an error "TypeError: Cannot interpolate with all NaNs."
What might be wrong here, how I can fix this?
Thanks.