<分区>
过滤我的结果数据框时出现问题。我的数据集中有一列名为 PaymentAmount
其中有数字数据,想执行一个操作来赋值
- 1 如果
data['PaymentAmount'] > 25000
和 - 0 如果
data['PaymentAmount'] <= 25000
我尝试使用下面的
1 if data['PaymentAmount'] >= 25000 else 0
但出现以下错误:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-176-e368653724d0> in <module>
----> 1 1 if data['PaymentAmount'] >= 25000 else 0
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\generic.py in __nonzero__(self)
1574 raise ValueError("The truth value of a {0} is ambiguous. "
1575 "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
-> 1576 .format(self.__class__.__name__))
1577
1578 __bool__ = __nonzero__
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().