In all seriousness this is an actual problem with numpy/pandas arrays where:
```
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.array([1, 2, 3])
array([1, 2, 3])
>>> bool(numpy.array([1, 2, 3]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: The truth value of an array with more than one element is
ambiguous. Use a.any() or a.all()
>>> bool(numpy.array([]))
<stdin>:1: DeprecationWarning: The truth value of an empty array is ambiguous.
Returning False, but in future this will result in an error. Use `array.size >
0` to check that an array is not empty.
False
>>> import pandas
>>> df = pandas.DataFrame()
>>> bool(df)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/home/graingert/.virtualenvs/redacted/lib/python3.8/site-packages/pandas/core/generic.py",
line 1537, in __nonzero__
raise ValueError(
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(),
a.item(), a.any() or a.all().
```
eg
https://pandas.pydata.org/pandas-docs/version/1.3.0/user_guide/gotchas.html#using-if-truth-statements-with-pandas
> Should it be True because it’s not zero-length, or False because there are
> False values? It is unclear, so instead, pandas raises a ValueError:
I'm not sure I believe the author here - I think it's clear. It should be True
because it's not zero-length.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/P7FA42SYR3DKSVSBAVLIHGSJXO3AT33G/
Code of Conduct: http://python.org/psf/codeofconduct/