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

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

代码

type(ams)

pandas.core.frame.DataFrame
fit = ss.genextreme.fit(ams)

报错信息

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
 in ()
----> 1 fit = ss.genextreme.fit(ams)
      2 print(fit)

~/anaconda3/lib/python3.6/site-packages/scipy/stats/_distn_infrastructure.py in fit(self, data, *args, **kwds)
   2278             raise TypeError("Too many input arguments.")
   2279 
-> 2280         if not np.isfinite(data).all():
   2281             raise RuntimeError("The data contains non-finite values.")
   2282 

~/anaconda3/lib/python3.6/site-packages/pandas/core/generic.py in __nonzero__(self)
   1477     def __nonzero__(self):
   1478         raise ValueError(
-> 1479             f"The truth value of a {type(self).__name__} is ambiguous. "
   1480             "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
   1481         )

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

解决方法

type(ams.values)

numpy.ndarray
fit = ss.genextreme.fit(ams.values)
print(fit)

(0.48070190276858693, 212.9835530676018, 36.562050718746406)

你可能感兴趣的:(日常报错)