unravel.tabular.filter_rows module#

Use tabular_filter_rows or filter_rows from UNRAVEL to filter tabular data by values in a specified column.

Usage to keep rows where ‘region’ contains ‘AUDp’:#

tabular_filter_rows -i data.csv -col region -p AUDp [–exact] [-o output_dir] [-v]

Usage to exclude rows where ‘region’ contains ‘layer1’:#

tabular_filter_rows -i data.csv -col region -p layer1 -f exclude [–exact] [-o output_dir] [-v]

unravel.tabular.filter_rows.parse_args()[source]#
unravel.tabular.filter_rows.filter_table(df, column, patterns, mode='include', exact=False)[source]#

Filter a DataFrame based on a specific column and a list of values.

Parameters:#

dfpandas.DataFrame

DataFrame containing the tabular data.

columnstr

Column name to filter by.

patternslist

List of values to filter by. If mode is ‘include’, rows with these values will be kept; if ‘exclude’, rows with these values will be removed.

modestr

Filtering mode, either ‘include’ (default) to keep rows with specified values or ‘exclude’ to remove them.

exactbool

If True, filter by exact matches of the values in the column. If False, filter by substring matches.

Returns:#

pandas.DataFrame or None

Filtered DataFrame if any rows match the criteria, otherwise None.

unravel.tabular.filter_rows.main()[source]#