简体   繁体   English

KeyError:“[Float64Index([34.62365962451697, 30.28671076822607, 35.84740876993872], dtype='float64')] 均不在 [columns] 中”

[英]KeyError: "None of [Float64Index([34.62365962451697, 30.28671076822607, 35.84740876993872], dtype='float64')] are in the [columns]"

This is my dataframe:这是我的数据框:

          x1         x2  y  x2_modified
0  34.623660  78.024693  0    99.294362
1  30.286711  43.894998  0   110.085855
2  35.847409  72.902198  0    96.249345

When i try to access the column x1 , it does it perfectly:当我尝试访问列x1 ,它完美地做到了:

>>> print(df.x1)
0    34.623660
1    30.286711
2    35.847409
Name: x1, dtype: float64

But when i try to plot it,但是当我试图绘制它时

df.plot(x = df.x1, y = df.x2_modified)

It gives above error:它给出了上述错误:

KeyError: "None of [Float64Index([34.62366, 30.286710999999997, 35.847409000000006], dtype='float64')] are in the [columns]" KeyError:“[Float64Index([34.62366, 30.2867109999999997, 35.847409000000006], dtype='float64')] 均不在 [columns] 中”

I'm not getting the reason, please help.我不明白原因,请帮忙。 Thanks.谢谢。

If want use DataFrame.plot only pass columns names:如果想使用DataFrame.plot只传递列名:

df.plot(x = 'x1', y = 'x2_modified')

If want use matplotlib.pyplot.plot then you can pass Series :如果想使用matplotlib.pyplot.plot那么你可以通过Series

plt.plot(df.x1, df.x2_modified)

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

相关问题 KeyError: Float64Index 都不在 [columns] 中,不确定如何继续 - KeyError: None of Float64Index are in the [columns], not sure how to proceed “[Float64Index([nan, nan], dtype='float64')] 中没有一个在 [index] 中”如果 col B 包含字符串,则设置 col A 值 - “None of [Float64Index([nan, nan], dtype='float64')] are in the [index]” setting col A value if col B contains string 尝试有条件地对 dataframe 中的某些元素求和,我得到 KeyError: “None of [Float64Index(...)] are in the [columns]” - Trying to conditionally sum some element in a dataframe, I obtain KeyError: “None of [Float64Index(…)] are in the [columns]” Python float64index浮动 - Python float64index to float 绘制平面 csv 列表会抛出 [Float64Index ... 中没有 [列]” - Plotting a flat csv list throws None of [Float64Index … are in the [columns]" 在Pandas DataFrame中格式化Float64Index - Formatting Float64Index in Pandas DataFrame 将 Panda Column dtype: float64 拆分为几列 - Split Panda Column dtype: float64 into several columns 使用Float64Index进行索引切片在熊猫中不起作用 - Index Slicing with Float64Index not working in pandas 在 DataSeries 中将 Dtype“object”更改为 Dtype“float64” - Changing Dtype "object" to Dtype "float64" in DataSeries 如何舍入熊猫 Float64Index? - How can I round a pandas Float64Index?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM