简体   繁体   English

关键错误:[Int64Index([…]dtype='int64')] 均不在 [columns] 中

[英]Key Error: None of [Int64Index([…]dtype='int64')] are in the [columns]

So here's my DataFrame:所以这是我的 DataFrame:

    a        b      c
0   1971    2154    203020339
1   1972    2648    191489250
2   1973    2690    193377651
3   1974    2676    201291002
4   1975    3276    275380446

I tried to make a very simple plot with it:我试图用它制作一个非常简单的 plot :

df.plot(x = df['a'], y = df['b'])

But I keep getting a Key Error message:但我不断收到一条关键错误消息:

None of [Int64Index([1971, 1972, 1973, 1974, 1975], dtype='int64')] are in the [columns]

I tried to use convert column [a] to DateTime but I still got the same error message.我尝试使用将列 [a] 转换为 DateTime,但仍然收到相同的错误消息。

df['a'] = pd.to_datetime(df['a'], format='%Y')

In the pandas plot, you already have a data frame, so the column name must be a name.在pandas plot中,你已经有了一个数据框,所以列名必须是一个名字。

df.plot(x='a', y='b')

在此处输入图像描述

暂无
暂无

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

相关问题 关键错误:[Int64Index…] dtype='int64] 均不在 [columns] 中 - Key Error: None of [Int64Index…] dtype='int64] are in the [columns] Sklearn 错误:[Int64Index([2, 3], dtype='int64')] 均不在 [columns] 中 - Sklearn error: None of [Int64Index([2, 3], dtype='int64')] are in the [columns] 读取 CSV & Columns - KeyError: “[Int64Index([0, 1, 2, 3], dtype='int64')] 都在 [columns] 中” - Reading CSV & Columns - KeyError: “None of [Int64Index([0, 1, 2, 3], dtype='int64')] are in the [columns]” KeyError:“[Int64Index dtype='int64', length=9313)] 都不在 [columns]” - KeyError: "None of [Int64Index dtype='int64', length=9313)] are in the [columns]" Receiving KeyError: “[Int64Index([ ... dtype='int64', length=1323)] 都不在 [columns]” - Receiving KeyError: "None of [Int64Index([ ... dtype='int64', length=1323)] are in the [columns]" Python Mlens Ensemble:KeyError:“[Int64Index([... dtype='int64', length=105)] 均不在 [columns] 中” - Python Mlens Ensemble: KeyError: "None of [Int64Index([... dtype='int64', length=105)] are in the [columns]" 关键错误:[Int64Index...] dtype='int64] 均不在列中 - Key Error: None of [Int64Index...] dtype='int64] are in the columns 关键错误:“[Int64Index...] dtype='int64] 均不在列中” - Key Error: "None of [Int64Index...] dtype='int64] are in the columns" [Int64Index([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype='int64', name='index')] 中没有一个在 [index] - None of [Int64Index([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype='int64', name='index')] are in the [index] 迭代并更改以熊猫为单位的行的值(错误“ [index]中[Int64Index([10],dtype ='int64')]都不存在”) - Iterating and changing value of the row in pandas ( Error “None of [Int64Index([10], dtype='int64')] are in the [index]” )
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM