【发布时间】:2020-06-06 01:27:44
【问题描述】:
我有以下列并希望将“Stores_num”更改为“Stores_Num”
data.columns
Out[240]:
Index(['INV_NUMBER', 'Store_num', 'Description', 'Price', 'Sold', 'Del',
'Sales', 'Tot_Sls', 'Unit_Cost', 'Cost', 'Cost_Percent', 'Margin',
'Profit', 'Date', 'Year', 'Month', 'Day'],
dtype='object')
我使用以下代码:
data.rename(columns={'Stores_num':'Stores_Num'},inplace=True)
data.columns
Out[242]:
Index(['INV_NUMBER', 'Store_num', 'Description', 'Price', 'Sold', 'Del',
'Sales', 'Tot_Sls', 'Unit_Cost', 'Cost', 'Cost_Percent', 'Margin',
'Profit', 'Date', 'Year', 'Month', 'Day'],
dtype='object')
如您所见,列名“Stores_num”没有改变。 这里有什么问题。
【问题讨论】:
-
'Store_num'不是'Stores_num' -
哦,废话……我的眼睛出卖了我……
标签: python-3.x pandas dataframe rename