pandas convert date to quarter

Solutions on MaxInterview for pandas convert date to quarter by the best coders in the world

showing results for - "pandas convert date to quarter"
Mía
22 Mar 2018
1df['quarter'] = pd.PeriodIndex(df.date, freq='Q')
2
3         date quarter
4s1 2018-03-22  2018Q1
5s2 2018-03-22  2018Q1
6s1 2018-06-22  2018Q2
7s2 2018-06-22  2018Q2
8s1 2018-09-22  2018Q3
9s2 2018-09-22  2018Q3
10