dtoolkit.accessor.series.filter_in#
- dtoolkit.accessor.series.filter_in(s: Series, condition: Iterable, /, complement: bool = False) Series[source]#
Filter
Seriescontents.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.isinpandas.Series.filterdtoolkit.accessor.dataframe.filter_inFilter DataFrame contents.
Examples
>>> import dtoolkit >>> import pandas as pd >>> s = pd.Series( ... ['lama', 'cow', 'lama', 'beetle', 'lama', 'hippo'], ... name='animal', ... ) >>> s 0 lama 1 cow 2 lama 3 beetle 4 lama 5 hippo Name: animal, dtype: object >>> s.filter_in(['cow', 'lama']) 0 lama 1 cow 2 lama 4 lama Name: animal, dtype: object >>> s.filter_in(['cow', 'lama'], complement=True) 3 beetle 5 hippo Name: animal, dtype: object