熊猫设置索引-KeyError

时间:2019-10-25 00:05:42

标签: python python-3.x pandas dataframe

我有下面一行可用,但使用了整个数据帧-希望仅使用两列进行内存优化。

df1 = df.set_index('Key Id')['Key Name']

更改为

df1 = df[('Key Id', 'Key Name')].set_index('Key Id', 'Key Name')

获取KeyError :(“键ID”,“键名称”)

我在这里错过了什么简单的事情?

0 个答案:

没有答案