0
votes

I have a Pandas timeseries where the Date indicates the last day of each month. I would like to change it so that it contains the first day of each Month. E.g., instead of '2018-08-31' to become '2018-08-01' and so on for all the Dates.

To that end I tried to resample using the 'convention' argument with the value 'start' but the method returned the timeseries intact.

For a reproducible example:

toy_data.to_json()
'{"GDP_Quarterly_Growth_Rate":{"-710294400000":-0.266691,"-707616000000":-0.266691,"-704937600000":-0.266691,"-702345600000":-0.206496,"-699667200000":-0.206496,"-697075200000":-0.206496,"-694396800000":1.564208,"-691718400000":1.564208,"-689212800000":1.564208,"-686534400000":1.504256}}'

toy_data.resample('M', convention = 'start').mean()

Returns the toy_data intact.

1

1 Answers

0
votes

Change M to MS, check offset aliases:

toy_data.resample('MS', convention = 'start').mean()