'How to convert to dates after removing the seasonality from the time series in python?

The question can be reframed as "How to remove daily seasonality from the dataset in python?" Please read the following: I have a time series and have used seasonal_decompose() from statsmodel to remove seasonality from the series. As I have used seasonal_decompose() on "Months" data, I get the seasonality only in months. How do I convert these months in to days/dates? Can I use seasonal_decompose() to remove daily seasonality? I tried one option of keeping frequency=365, but it raises following error:

 x must have 2 complete cycles requires 730 observations. x only has 24 observation(s)

Snippet of the code:

grp_month = train.append(test).groupby(data['Month']).sum()['Var1']
season_result = seasonal_decompose(grp_month, model='addition', period=12)

This gives me the output:

Month Out
2018-01-01 -17707.340278
2018-02-01 -49501.548611
2018-03-01 -28172.590278
.. ..
.. ..
2019-12-01 -13296.173611

As you can see in the table, implementing seasonal_decompose() gives me the monthly seasonality. Is there any way I can get the daily data from this? Or can I convert this into a date wise series?

Edit: I tried to remove daily seasonality as follows but I'm not really sure if this is the way to go.

 period = 365
 season_mean = data.groupby(data.index % period).transform('mean') 
 data -= season_mean
 print(data.head())


Solution 1:[1]

If you want to substract these values to a daily DataFrame, you should upsample the DataFrame season_result using pandas.DataFrame.resample this way you will be able to substract the monthly seasonnality from your original one.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Virgaux Pierre