Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pandas 如何在不写每个名字的情况下删除列?_Pandas_Python 2.7 - Fatal编程技术网

Pandas 如何在不写每个名字的情况下删除列?

Pandas 如何在不写每个名字的情况下删除列?,pandas,python-2.7,Pandas,Python 2.7,我还不知道会是什么样子,因为我不想记住列的名称,也可能我的列是整数,只是按我感兴趣的位置删除它们,知道吗?没有关于文档的信息 多谢各位 更新 例如: 如何在列中按索引删除* 我的DF: help ... success _links https://opendata.com/data... ... True fields https://opendata.com/data... ...

我还不知道会是什么样子,因为我不想记住列的名称,也可能我的列是整数,只是按我感兴趣的位置删除它们,知道吗?没有关于文档的信息

多谢各位

更新

例如:

如何在列中按索引删除* 我的DF:

                                     help  ... success
_links       https://opendata.com/data...  ...    True
fields       https://opendata.com/data...  ...    True

问题是原始解决方案不起作用,因为
df
是列表

所以首先更新为列表,然后转换为数据帧以避免它

然后正确工作:

#remove columns by indexing
df1 = df1.drop(df1.columns[[0, 1, 3]], axis=1)

使用
df=df.drop(df.columns[[0,1,3]],axis=1)
AttributeError:'list'对象没有属性'drop',我试过了,还删除了df[[0,1,2,3]],但不需要编辑。我用
df=df.DataFrame({'A':list('abcdef'),'B':[4,5,4,5,5,4],'C':[7,8,9,4,2,3],'D':[1,3,5,7,1,0],'E':[5,3,6,9,2,4],'F':list('aaabbb'))测试数据帧
,使用
df-drop(df.columns[[0,1,2,3],'axis=1])测试数据帧是否正常工作。如果有样本列表,请更改数据列表,免费使用上面评论中的数据样本。最好更新为列表,然后转换为数据帧…;)重现错误
#remove columns by indexing
df1 = df1.drop(df1.columns[[0, 1, 3]], axis=1)