Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.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 - Fatal编程技术网

Pandas 如何删除";“奇怪”;数据帧中的列

Pandas 如何删除";“奇怪”;数据帧中的列,pandas,Pandas,此代码返回dfESPCTC列名的名称 print list(dfESPCTC.columns.values) [('DateTime', ''), (u'bid', 'close'), (u'bid', 'high'), (u'bid', 'low'), (u'bid', 'open')] 如何从数据帧中删除除关闭之外的所有内容?我试过了,但没用 dfESPCTC = dfESPCTC.drop('(bid, high)', 1) 您的数据帧有一列。要除去关闭列以外的所有列,只需选择一列:

此代码返回
dfESPCTC
列名的名称

print list(dfESPCTC.columns.values)

[('DateTime', ''), (u'bid', 'close'), (u'bid', 'high'), (u'bid', 'low'), (u'bid', 'open')]
如何从数据帧中删除除关闭之外的所有内容?我试过了,但没用

dfESPCTC = dfESPCTC.drop('(bid, high)', 1)

您的数据帧有一列。要除去
关闭
列以外的所有列,只需选择一列:

dfESPCTC = dfESPCTC[[(u'bid', 'close')]]
如果使用列表为dfESPCTC编制索引,则结果为数据帧。 如果只传递列元组(例如,
dfESPCTC[(u'bid','close')]
),则结果是一个序列