pandas datetime data to year quarter average 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