I would like to filter the df below by last business day in a month;
so the result should show only 2022-08-31 and 2022-07-29 as those were the last business days in the months.
Please keep in mind the original df has thousands of rows when writing the solution. Thanks!
import pandas as pd
d = pd.to_datetime(['2022-08-01','2022-08-02','2022-08-03','2022-08-04','2022-08-31',
'2022-07-01','2022-07-02','2022-07-03','2022-07-04','2022-07-29'])
df = pd.DataFrame()
df['date'] = d
print(df)
date
0 2022-08-01
1 2022-08-02
2 2022-08-03
3 2022-08-04
4 2022-08-31
5 2022-07-01
6 2022-07-02
7 2022-07-03
8 2022-07-04
9 2022-07-29