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