Suppose I have a pandas data frame with multiple columns- something like this
targetName ... atRiskCommonPurchased
0 Twitter, Inc. ... NaN
1 Forbes Media ... NaN
2 Adobe ... NaN
3 Virgin Airlines ... NaN
4 H&M ... NaN
[5 rows x 51 columns]
And I have also have a column in the same data frame which is of dates:
df['dealAnnouncementDate'].dtype
dtype('O')
print(df['dealAnnouncementDate'])
0 2021-08-30
1 2021-08-26
2 2021-08-25
3 2021-08-23
4 2021-08-18
using df.between() I can easily filter the dataframe using the date column and get the result. something like: df[df['dealAnnouncementDate'].between('7/27/2021', '8/27/2021')]
But, I would be runnning the python script on every 7th day(take for instance Monday), How do I ensure that using dealAnnouncementDate column I get filtered results for 7 days? Please help me to understand how can it be done! Thanks!