Suppose I have a certain defined range of dates, e.g. 2022-12-25
to 2023-02-05
.
I want to find all fully closed periods (specified by the user) that fit into this date range. For example, if the user specifies months
and decades
, the method should return
2023-01-01
to2023-01-10
,decade
12023-01-11
to2023-01-20
,decade
22023-01-21
to2023-01-31
,decade
32023-01-01
to2023-01-31
,month
1
Another example would be finding all fully closed seasons (DJF, MMA, JJA, SON) and years in 2021-12-31
to 2023-02-28
, which should result in
2022-01-01
to2022-12-31
,year
12022-03-01
to2022-04-30
,season
1 (MMA, spring)2022-05-01
to2022-08-31
,season
2 (JJA, summer)2022-09-01
to2022-11-30
,season
3 (SON, fall)2022-12-01
to2023-02-28
,season
4 (DJF, winter)
Is there a way to find this in pandas easily without many if/else conditions?