回答編集履歴
1
説明追加
answer
CHANGED
@@ -18,4 +18,19 @@
|
|
18
18
|
その説明は、[公式ドキュメント Python 標準ライブラリ dis --- Python バイトコードの逆アセンブラ](https://docs.python.org/ja/3/library/dis.html)をお読みください。
|
19
19
|
|
20
20
|
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
|
21
|
-
といエラーが出るのは、pandas.Seriesの場合には、JUMP_IF_TRUE_OR_POPでの```__bool__```をそうなるように上書きしているためです。
|
21
|
+
といエラーが出るのは、pandas.Seriesの場合には、JUMP_IF_TRUE_OR_POPでの```__bool__```をそうなるように上書きしているためです。
|
22
|
+
|
23
|
+
```python
|
24
|
+
>>> import pandas as pd
|
25
|
+
>>> s = pd.Series([True, False])
|
26
|
+
>>> print(s)
|
27
|
+
0 True
|
28
|
+
1 False
|
29
|
+
dtype: bool
|
30
|
+
>>> bool(s)
|
31
|
+
Traceback (most recent call last):
|
32
|
+
File "<stdin>", line 1, in <module>
|
33
|
+
File "C:\Users\shinp\anaconda3\envs\sandbox\lib\site-packages\pandas\core\generic.py", line 1537, in __nonzero__
|
34
|
+
raise ValueError(
|
35
|
+
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
|
36
|
+
```
|