Skip to content

bool() operation on DataFrame should throw ValueError #1069

Closed
@dtcaciuc

Description

@dtcaciuc

DataFrame should behave consistently with Series and NumPy arrays when used in boolean comparison. Additionally, should provide consistent all/any behaviour.

>>> from pandas import *
>>> s = Series([1, 2, 3]) 
>>> bool(s)   
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()
>>> d = DataFrame([[1,2,3]])
>>> bool(d)
True  # should throw ValueError as well
>>> all(s)
True
>>> all(d)
False # should be True

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions