I have the following pandas dataframe:
import pandas as pd
foo = pd.DataFrame({'week': [1,2,4,5,7], 'items':[1,2,3,4,5]}
I would like to fill foo
with rows for the "missing" weeks from 1
to 7
and then for these rows the items
column should have as value the previous non-na value
The output dataframe should look like this:
foo = pd.DataFrame({'week': [1,2,3,4,5,6,7], 'items':[1,2,2,3,4,4,5]}
How could I do that ?