[英]Pandas dataframe column with title 'name'
I have multiple dataframes which I join based on a common column.我有多个基于公共列加入的数据框。 The code looks like this:代码如下所示:
df=reduce(lambda x,y:pd.merge(x,y,on='name'),[total,eliminated, actionable, bug])
Afterwards, I intend to rename the column name
.之后,我打算重命名列name
。 But name
is not anymore in the column list.但是name
不再出现在列列表中。 When I print the df
, the name column shows but I don't know how to work with that merged column anymore, like renaming.当我打印df
时,会显示名称列,但我不知道如何再使用该合并列,例如重命名。
If I print type(df), df.columns, df
, it shows:如果我打印type(df), df.columns, df
,它会显示:
(pandas.core.frame.DataFrame,
Index(['total', 'e', 'a', 'b'], dtype='object'),
total e a b
name
!CHAOS Control System 282 80.14 39.01 1.42
Chromium EC 306 93.46 29.74 17.65
Firefox 5448 77.22 49.72 12.43
What happended to the name
column and how can I rename it afterwards? name
列发生了什么,之后如何重命名?
It looks like you set 'name' as the index.看起来您将“名称”设置为索引。 Try this:尝试这个:
df = df.reset_index()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.