DataFrame.filter

DataFrame.filter(items: Sequence[str] | None = None, like: str | None = None, regex: str | None = None, axis: int | str | None = None) DataFrame[source]

Subset the dataframe rows or columns according to the specified index labels. Note that this routine does not filter a dataframe on its contents. The filter is applied to the labels of the index.

Parameters

itemslist-like

Keep labels from axis which are in items.

likestr

Keep labels from axis for which “like in label == True”.

regexstr (regular expression)

Keep labels from axis for which re.search(regex, label) == True.

axis{0 or ‘index’, 1 or ‘columns’, None}, default None

The axis to filter on, expressed either as an index (int) or axis name (str). By default this is the info axis, ‘index’ for Series, ‘columns’ for DataFrame.

Returns

opensearch_py_ml.DataFrame

See Also

:pandas_api_docs:`pandas.DataFrame.filter`

Notes

The items, like, and regex parameters are enforced to be mutually exclusive.