'Group dates based on the card payment date(17th~18th of next month)

I am trying to analyze 3 years' worth of card usage history (2019-2021). I'm trying to group data by payment date, but it's not possible by 'pd.date_range(periods=30)'. Card payment is from the 18th of each month to the 17th of the following month.

I can't use Pandas date_range period function so that is not a same period per every month. ex> pd.date_range('2021-12-01', periods=30)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source