Open
Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
I would like to check, element-wise, if a pd.Series
is contained within a pd.Interval
, ie.
pd.Series(range(10)) in pd.Interval(0, 1)
Feature Description
pd.Interval.__contains__
would have to check for a pd.Series
type and then call
def __contains__(self, item: Any) -> bool | pd.Series:
...
if isinstance(item, pd.Series):
return item.apply(lambda element: element in self)
Alternative Solutions
It's easy enough to write pd.Series(range(10)).apply(lambda element: element in pd.Interval(0, 1)
, but the syntactic sugar proposed here would be nice.
Additional Context
No response