how to get quarter year date in pandas code example
Example 1: how to get quarter year date in pandas
df['quarter'] = df['date'].dt.quarter
Example 2: how to get quarter year date in pandas
import datetime as dt
import pandas as pd
quarter = pd.Timestamp(dt.date(2016, 2, 29)).quarter
assert quarter == 1
Example 3: how to get quarter year date in pandas
for m in range(1, 13):
print (m-1)//3 + 1,
print