how to get quarter year date in pandas 1

how to get quarter year date in pandas

df['quarter'] = df['date'].dt.quarter

Here is what the above code is Doing:
1. We’re creating a new column called ‘quarter’
2. We’re using the .dt accessor to access the datetime object
3. We’re using the .quarter method to get the quarter of the datetime object

Similar Posts