dtoolkit.accessor.series.filter_in#
- dtoolkit.accessor.series.filter_in(s: Series, condition: Iterable, /, complement: bool = False) Series [source]#
Filter
Series
contents.Similar to
isin()
, but the return is not bool.- Parameters:
- conditionlist-like
The filtered result is based on this specific condition.
- complementbool, default is False
If True, do operation reversely.
- Returns:
- Series
See also
pandas.Series.isin
pandas.Series.filter
dtoolkit.accessor.dataframe.filter_in
Filter DataFrame contents.
Examples
>>> import dtoolkit >>> import pandas as pd >>> s = pd.Series( ... ['llama', 'cow', 'llama', 'beetle', 'llama', 'hippo'], ... name='animal', ... ) >>> s 0 llama 1 cow 2 llama 3 beetle 4 llama 5 hippo Name: animal, dtype: object >>> s.filter_in(['cow', 'llama']) 0 llama 1 cow 2 llama 4 llama Name: animal, dtype: object >>> s.filter_in(['cow', 'llama'], complement=True) 3 beetle 5 hippo Name: animal, dtype: object