当我在数据透视表上调用重命名时,我丢失了轴标签:
In [5]: df = pd.DataFrame(dict(x=[0,0,1,0,1], y=[1,0,1,1,0], z=[0,0,1,0,1]))
In [6]: pt = pd.pivot_table(df, 'z', cols='x', rows='y')
In [7]: print pt
x 0 1
y
0 0 1
1 0 1
In [8]: labels = {0:'False', 1:'True'}
In [9]: print pt.rename(index=labels, columns=labels) # discards "x" and "y"
False True
False 0 1
True 0 1
有没有办法在不丢失轴标签的情况下做到这一点?