I am having troubles converting the column names in my pandas dataframe according to the dictionary I have created
housing = pd.read_csv('City_Zhvi_AllHomes.csv')
cols = housing.iloc[:,51:251]
housing = housing.drop(list(housing)[6:251],axis=1)
cols = cols.groupby(np.arange(len(cols.columns))//3, axis=1).mean()
a= pd.read_excel('gdplev.xls', header=None, skiprows=220,index_col=0, names=['GDP'], parse_cols=[4,6])
col_names = list(a.index)
col_names = col_names + ['2016q3']
vals = list(cols.columns.values)
cols_dict = dict(zip(col_names,vals))
cols = cols.rename(columns = cols_dict)
I also tried using the map function:
cols.columns.map([cols_dict])
The desired outcome is to convert all the column names (0-66) to they keys listed in my dictionary (2000q1-2016q3)
However, the two solutions I have implemented yield the same results and the columns remain with the same names.
UPDATE As requested here is a list of the first few rows from my dataframe:
0 1 2 3 4 5 6 7 8 9 ... 57 58 59 60 61 62 63 64 65 66
0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... 5.154667e+05 5.228000e+05 5.280667e+05 5.322667e+05 5.408000e+05 5.572000e+05 5.728333e+05 5.828667e+05 5.916333e+05 587200.0
1 2.070667e+05 2.144667e+05 2.209667e+05 2.261667e+05 2.330000e+05 2.391000e+05 2.450667e+05 2.530333e+05 2.619667e+05 2.727000e+05 ... 4.980333e+05 5.090667e+05 5.188667e+05 5.288000e+05 5.381667e+05 5.472667e+05 5.577333e+05 5.660333e+05 5.774667e+05 584050.0
2 1.384000e+05 1.436333e+05 1.478667e+05 1.521333e+05 1.569333e+05 1.618000e+05 1.664000e+05 1.704333e+05 1.755000e+05 1.775667e+05 ... 1.926333e+05 1.957667e+05 2.012667e+05 2.010667e+05 2.060333e+05 2.083000e+05 2.079000e+05 2.060667e+05 2.082000e+05 212000.0
3 5.300000e+04 5.363333e+04 5.413333e+04 5.470000e+04 5.533333e+04 5.553333e+04 5.626667e+04 5.753333e+04 5.913333e+04 6.073333e+04 ... 1.137333e+05 1.153000e+05 1.156667e+05 1.162000e+05 1.179667e+05 1.212333e+05 1.222000e+05 1.234333e+05 1.269333e+05 128700.0
And a sample of my dictionary:
{0: '2000q1',
1: '2000q2',
2: '2000q3',
3: '2000q4',
4: '2001q1',
5: '2001q2',