Open
Description
Feature Type
- Changing existing functionality in pandas
Problem Description
For compatibility reasons with numpy.where
it would be nice to allow scalar booleans as a condition to Series.where
and DataFrame.where
. Currently
import pandas as pd
s = pd.Series([1,2])
s.where(True)
raises ValueError: Array conditional must be same shape as self
Feature Description
Allow scalar boolean as input to
Series.where
Series.mask
DataFrame.where
DataFrame.mask
Alternative Solutions
idk.
Additional Context
Regarding documentation, I am not sure anything needs to be updated since both Series.where
and DataFrame.where
specify array-like
as a valid input type, and scalars are considered array-like
.