I have a df that has the following, df.dtypes
:
key object
date datetime64[ns]
username object
answer object
grade object
dtype: object
I then group by week:
test_lastweek = df.groupby([pd.Grouper(key='date', freq='W-SAT')])['key'].count()
I can see that that are 45 records that fall with in the last week of 2019-08-17
:
date
2019-06-29 475
2019-07-06 294
2019-07-13 2311
2019-07-20 389
2019-07-27 554
2019-08-03 408
2019-08-10 587
2019-08-17 45
Freq: W-SAT, Name: key, dtype: int64
Question: How do I get the last weeks data, all 45 records with the data from df
and make that into a new df?