I have a dataset \'City\' with Column names
2000-01,2000-02,2000-03,2000-04,2000-05,......,2010-08,2010-09,2010-10,2010-11,2010-12.
I used
You need strftime
what works with PeriodIndex
:
hd.columns = hd.columns.strftime('%Yq%q')
Sample:
hd = pd.DataFrame({'2000-01':[1,3], '2000-05':[5,6]})
hd = hd.groupby(pd.PeriodIndex(hd.columns, freq='Q'), axis =1).mean()
print (hd)
2000Q1 2000Q2
0 1 5
1 3 6
hd.columns = hd.columns.strftime('%Yq%q')
print (hd)
2000q1 2000q2
0 1 5
1 3 6