Closed
Description
This is also a documentation error, as the docs say the default axis is axis = 0
import pandas as pd
from pandas.util.testing import makePanel
#
# Demo A: We want to fill along axis 0
#
p = makePanel().transpose(1,0,2)
p.iloc[10:20,0,0] = np.nan
# Demonstrate we have a gap
p.iloc[:,0,0].plot()
# Demonstrate that nothing seems to fill the gap
p.fillna(method='ffill').iloc[:,0,0].plot()
p.fillna(method='ffill', axis=0).iloc[:,0,0].plot()
p.fillna(method='ffill', axis=1).iloc[:,0,0].plot()
p.fillna(method='ffill', axis=2).iloc[:,0,0].plot()
# At least one of the above should be the same as:
p.apply(lambda series: series.fillna(method='ffill'), axis=0).iloc[:,0,0].plot()
#
# Demo B: We want to fill along axis 1
#
p = makePanel()
p.iloc[0, 10:20,0] = np.nan
# Demonstrate we have a gap
p.iloc[0,:,0].plot()
# Demonstrate the gap is filled regardless of the axis
p.fillna(method='ffill').iloc[0,:,0].plot()
p.fillna(method='ffill', axis=0).iloc[0,:,0].plot()
p.fillna(method='ffill', axis=1).iloc[0,:,0].plot()
p.fillna(method='ffill', axis=2).iloc[0,:,0].plot()