gpt4 book ai didi

python - Matplotlib 与 Pandas : Elementwise comparison failed

转载 作者:行者123 更新时间:2023-11-28 17:34:07 24 4
gpt4 key购买 nike

我正在使用 pandas 和 matplotlib 构建条形图。我需要错误栏,但我的函数没有创建它们,我收到以下消息:

C:\Python27\lib\site-packages\matplotlib\collections.py:590: FutureWarning: elementwise comparison failed; returning sca
lar instead, but in the future will perform elementwise comparison
if self._edgecolors == str('face'):

根据 pandas 绘图文档:

The error values can be specified using a variety of formats.

As a DataFrame or dict of errors with column names matching the columns attribute of the plotting DataFrame or matching the name attribute of the Series
As a str indicating which of the columns of plotting DataFrame contain the error values
As raw values (list, tuple, or np.ndarray). Must be the same length as the plotting

我有以下内容:

recsFrame_mean = recsFrame.groupby('REGIONC').mean()

recsFrame_mean.plot(y='weighted_KWH',yerr='se_KWH', kind='bar')

recsFrame_mean 具有以下结构:

>>> print(recsFrame_mean)
DIVISION REPORTABLE_DOMAIN TYPEHUQ NWEIGHT HDD65 \
REGIONC
1 1.586055 2.734775 2.997793 9166.128420 5894.129303
2 3.595498 9.556806 2.476609 9116.257475 6285.651425
3 5.751589 17.612958 2.558924 10288.546455 2436.917604
4 9.564147 25.390777 2.717060 8615.848474 3067.628294

... PERIODLP SCALELP PERIODFO SCALEFO PERIODKR \
REGIONC ...
1 ... -1.536187 -1.684025 -0.392763 -0.897617 -1.854810
2 ... -1.523039 -1.676750 -1.906437 -1.934576 -1.945480
3 ... -1.528117 -1.679951 -1.945477 -1.963325 -1.951100
4 ... -1.650485 -1.758322 -1.971221 -1.980583 -1.968793

SCALEKER NGHSQFT ELECHSQFT weighted_KWH se_KWH
REGIONC
1 -1.897617 0.402426 5.895109 7.407772e+07 7923.790058
2 -1.962715 0.405440 7.297165 9.647961e+07 11282.706985
3 -1.966259 0.138032 10.506909 1.498108e+08 14699.751866
4 -1.978155 0.299447 7.095108 8.017829e+07 8982.045134

[4 rows x 931 columns]

最佳答案

我在通过有时不稳定的 pandas 绘制错误栏时遇到了问题。试试 yerr=list(recsFrame_mean['se_KWH']),因为我认为这对我来说一直是一种有效的方法。

关于python - Matplotlib 与 Pandas : Elementwise comparison failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32110269/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com