简体   繁体   English

在熊猫问题中删除专栏

[英]Dropping column in pandas issue

This is sample of my dataset 这是我的数据集的样本

id   imdb_id  popularity  budget     revenue   cast         runtime
1357 0        3.1         150000000  20000000  Chris Pratt  124

and here is my code 这是我的代码

df.drop(['imdb_id', 'cast', 'runtime'], axis=1 , inplace=True)

i got this error 我得到这个错误

ValueError: labels ['imdb_id' 'cast', 'runtime'] not contained in axis ValueError:轴中不包含标签['imdb_id''cast','runtime']

I noticed a missing , in labels ['imdb_id' 'cast', 'runtime'] . 我注意到一个丢失的,labels ['imdb_id' 'cast', 'runtime']

Could that be the problem? 这可能是问题吗?

Otherwise, make sure the names of the columns do not contain white spaces by printing df.columns 否则,请通过打印df.columns确保列名中不包含空格。

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

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