简体   繁体   English

df.drop无法正常工作

[英]df.drop is not working

I am very stuck with this, obviously I have little experience, so every opinion is welcome: 我对此很固执,显然我经验不足,因此欢迎提出每种意见:

df = pd.concat((pd.read_csv(f,delimiter = '|') for f in onlyfiles)
# I have to delete the column 'Unnamed: 0'
df = df.drop(['Unnamed: 0'])
df.head()

If somebody can tell something about this 'Unnamed: 0' column, I don't understand what's the use of this? 如果有人可以说出有关“未命名:0”列的信息,我不知道这有什么用?

Thanks! 谢谢!

DOCS DOCS

'Unnamed: 0' is a column name. 'Unnamed: 0'是列名。 You'll need to pass the axis=1 parameter to drop 您需要传递axis=1参数才能drop

df = df.drop(['Unnamed: 0'], axis=1)

Because the axis parameter is the second parameter, that can be shortened to 由于axis参数是第二个参数,因此可以缩短为

df = df.drop(['Unnamed: 0'], 1)

如果您想将该列放到原位,则有另一种方法。

del(df['Unnamed: 0'])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM