So I have a table as shown. It has a date quarter of the year and a SoldItems column. I would like to change it to words and also have it in Fiscal year quarters where Jan-Mar =Qtr4, Apr-Jun = Qtr1, Jul-Sep =Qtr2, Oct-Dec =Qtr3.
0 2019-01-01 1 23
1 2019-01-02 1 87
2 2019-01-03 1 54
3 2019-01-04 1 63
4 2019-01-05 1 14
How do I do that?
CodePudding user response:
Another method using pd.cut
:
bins = [0,3,6,9,12]
pd.cut(df[2], bins = bins, labels = [f'Qtr{i}' for i in range(1,len(bins))])