python - Formatting Quarter time in pandas columns - Stack Overflow

PHOTO EMBED

Sun Aug 09 2020 10:49:39 GMT+0000 (Coordinated Universal Time)

Saved by @arielvol

import pandas as pd
df = pd.DataFrame({"y": [1,2,3]}, 
                  index=pd.to_datetime(["2000-03-31 00:00:00", "2000-05-31 00:00:00", "2000-08-31 00:00:00"]))

df.index = df.index.to_period("Q")
df
#       y
#2000Q1 1
#2000Q2 2
#2000Q3 3
content_copyCOPY

https://stackoverflow.com/questions/41369227/formatting-quarter-time-in-pandas-columns