macpie.pandas.filter_labels#
- macpie.pandas.filter_labels(*dfs: DataFrame, axis=None, filter_level=None, result_level=None, result_type='single_list', **kwargs)#
Filter dataframe row or column labels. The options
items
,like
, andregex
are additive and can be used in conjunction with one another.- Parameters:
- dfsSequence of DataFrames
- axis{0 or index, 1 or columns, None}, default None
The axis to filter labels on, expressed either as an index (int) or axis name (str). By default this is the info axis, ‘index’ for Series, ‘columns’ for DataFrame.
- filter_levelstr or int, optional
For a MultiIndex, level (name or number) to use for filtering. Supports negative indexing (i.e. -1 is highest level).
- result_levelstr or int, optional
For a MultiIndex, return the labels at the requested level (name or number). Default is returning all levels.
- result_type{‘single_list’, ‘single_list_no_dups’, ‘list_of_lists’}, default ‘single_list_no_dups’
Indicates how results should be returned.
single_list: Results are flattened into a single list
single_list_no_dups: Results are flattened into a single list with duplicates removed
list_of_lists: List of lists.
- **kwargs
All remaining keyword arguments are passed through to the underlying
macpie.lltools.filter_seq()
function to perform the actual filtering.
- Returns:
- List of labels. See
result_type
parameter.
- List of labels. See
See also
DataFrame.filter
Subset the dataframe rows or columns according to the specified index labels.