Skip to content
Advertisement

Output missing dates by group of columns

I have time series of y per store and product stored in the following dataframe:

JavaScript

I would like to output all the missing dates per store, product and return the following result:

JavaScript

Advertisement

Answer

Use groupby_resample:

JavaScript

Details:

JavaScript

Update: If you have a date in the ds column without a value in the y column, just use fillna({'y': 0}) before groupby_resample

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement