回答編集履歴
1
説明追加
test
CHANGED
@@ -39,3 +39,33 @@
|
|
39
39
|
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
|
40
40
|
|
41
41
|
といエラーが出るのは、pandas.Seriesの場合には、JUMP_IF_TRUE_OR_POPでの```__bool__```をそうなるように上書きしているためです。
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
```python
|
46
|
+
|
47
|
+
>>> import pandas as pd
|
48
|
+
|
49
|
+
>>> s = pd.Series([True, False])
|
50
|
+
|
51
|
+
>>> print(s)
|
52
|
+
|
53
|
+
0 True
|
54
|
+
|
55
|
+
1 False
|
56
|
+
|
57
|
+
dtype: bool
|
58
|
+
|
59
|
+
>>> bool(s)
|
60
|
+
|
61
|
+
Traceback (most recent call last):
|
62
|
+
|
63
|
+
File "<stdin>", line 1, in <module>
|
64
|
+
|
65
|
+
File "C:\Users\shinp\anaconda3\envs\sandbox\lib\site-packages\pandas\core\generic.py", line 1537, in __nonzero__
|
66
|
+
|
67
|
+
raise ValueError(
|
68
|
+
|
69
|
+
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
|
70
|
+
|
71
|
+
```
|