解决 ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a

谁借莪1个温暖的怀抱¢ 2023-02-26 13:23 130阅读 0赞

fit(ams) 报错 ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

代码

  1. type(ams)
  2. pandas.core.frame.DataFrame
  3. fit = ss.genextreme.fit(ams)

报错信息

  1. ---------------------------------------------------------------------------
  2. ValueError Traceback (most recent call last)
  3. <ipython-input-19-159c24c8aa15> in <module>()
  4. ----> 1 fit = ss.genextreme.fit(ams)
  5. 2 print(fit)
  6. ~/anaconda3/lib/python3.6/site-packages/scipy/stats/_distn_infrastructure.py in fit(self, data, *args, **kwds)
  7. 2278 raise TypeError("Too many input arguments.")
  8. 2279
  9. -> 2280 if not np.isfinite(data).all():
  10. 2281 raise RuntimeError("The data contains non-finite values.")
  11. 2282
  12. ~/anaconda3/lib/python3.6/site-packages/pandas/core/generic.py in __nonzero__(self)
  13. 1477 def __nonzero__(self):
  14. 1478 raise ValueError(
  15. -> 1479 f"The truth value of a {type(self).__name__} is ambiguous. "
  16. 1480 "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
  17. 1481 )
  18. ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

解决方法

  1. type(ams.values)
  2. numpy.ndarray
  3. fit = ss.genextreme.fit(ams.values)
  4. print(fit)
  5. (0.48070190276858693, 212.9835530676018, 36.562050718746406)

欢迎大家交流学习,任何问题都可以留言

发表评论

表情:
评论列表 (有 0 条评论,130人围观)

还没有评论,来说两句吧...

相关阅读