2021年1月23日星期六

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

So here's my 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:

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.

df['a'] = pd.to_datetime(df['a'], format='%Y')  
https://stackoverflow.com/questions/65865201/key-error-none-of-int64index-dtype-int64-are-in-the-columns January 24, 2021 at 06:38AM

没有评论:

发表评论