Python 无法重命名列系列
我无法重命名系列的列:Python 无法重命名列系列,python,pandas,Python,Pandas,我无法重命名系列的列: tabla_paso4 Date decay 2015-06-29 0.003559 2015-09-18 0.025024 2015-08-24 0.037058 2014-11-20 0.037088 2014-10-02 0.037098 Name: decay, dtype: float64 我试过: tabla_paso4.rename('decay_acumul') tabla_paso4.rename(
tabla_paso4
Date decay
2015-06-29 0.003559
2015-09-18 0.025024
2015-08-24 0.037058
2014-11-20 0.037088
2014-10-02 0.037098
Name: decay, dtype: float64
我试过:
tabla_paso4.rename('decay_acumul')
tabla_paso4.rename(columns={'decay':'decay_acumul'}
我已经看过了可能的副本,但不知道为什么,尽管申请:
tabla_paso4.rename(columns={'decay':'decay_acumul'},inplace=True)
按如下方式返回序列:
Date
2015-06-29 0.003559
2015-09-18 0.025024
2015-08-24 0.037058
2014-11-20 0.037088
2014-10-02 0.037098
dtype: float64
试一试
或
您之前做错的是,您错过了inplace=True
部分,因此返回了重命名的df,但没有分配
我希望这有帮助 看起来您的
表格是一个系列,而不是数据帧
您可以使用命名列创建数据框:
new_df = tabla_paso4.to_frame(name='decay_acumul')
感谢@Thanos对您的帮助,这可能是重复的。不知道为什么现在没有指定姓名。
tabla_paso4.rename(columns={'decay':'decay_acumul'}, inplace=True)
new_df = tabla_paso4.to_frame(name='decay_acumul')