-1

I have the following dataframe: data

Out[8]: 
            Population
date                           
1980-11-03               1591.4
1980-11-10               1592.9
1980-11-17               1596.3
1980-11-24               1597.2
1980-12-01               1596.1
                        ...
2020-06-01              18152.1
2020-06-08              18248.6
2020-06-15              18328.9
2020-06-22              18429.1
2020-06-29              18424.4

[2070 rows x 1 columns]

If i resample it over a year i will get this:

data.resample('Y').mean()

date                           
1980-12-31          1596.144444
1981-12-31          1678.686538
1982-12-31          1829.826923

Is it possible for it to be resampled in way such that it is resampled ending on a specific date such as Jan 1st. Thus the dates would be 1980 - 1 -1 in the above example instead of 1980-12-31.

Slartibartfast
  • 1,058
  • 4
  • 26
  • 60

1 Answers1

1

What we can do is change to YS

df.resample('YS').mean()
BENY
  • 317,841
  • 20
  • 164
  • 234