[英]how to drop the title for data-frame columns
I come up with a dataframe like this, I wonder how can we change or drop the 'id' and 'date' as they are just the names for index and columns. 我想出了一个这样的数据框,我想知道如何才能更改或删除“ id”和“ date”,因为它们只是索引和列的名称。
id col1 col2 clo3
date
2000-01-03 55.500000 NaN NaN
2000-01-04 52.812500 NaN NaN
2000-01-05 52.750000 NaN NaN
2000-01-06 53.500000 NaN NaN
2000-01-07 53.625000 NaN NaN
2000-01-10 52.656250 NaN NaN
Option 1 选项1
rename_axis
df.rename_axis(None, 1, inplace=True) # 1 is for axis=1
Option 2 选项2
reassign df.columns
重新分配
df.columns
df.columns = df.columns.tolist()
Option 3 选项3
Setting the name
attribute, as described by Boud . 设置
name
属性,如Boud所述 。
df.columns.name = None
df.index.name = None
These variables are represented through the name
property: 这些变量通过
name
属性表示:
df.columns.name = None
df.index.name = None
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.