get_filter_df_by_prefixes_index
- get_filter_df_by_prefixes_index(df: DataframeOrSeries, *, column: str | int | None = None, prefixes: str | Collection[str], method: PrefixIndexMethod | None = None, validate: bool = False, converter: Converter | None = None) pd.Series[bool][source]
Get an index of CURIEs in the given column that start with the prefix(es).
- Parameters:
df – A dataframe or series. If a dataframe is given, the
columnmust not be none.column – The column to check, if a dataframe was passed. If a series was passed, this can be left as none.
prefixes – The prefix or set of prefixes to identify
method – The indexing method
validate – Should the prefixes be validated against the converter?
converter – A converter for validating CURIEs
- Returns:
A pandas boolean series that corresponds to the rows of the dataframe or series provided
- Raises:
ValueError – If validation is set to true but no converter is passed
Example usage:
import pandas as pd from curies.dataframe import get_filter_df_by_prefixes_index rows = [ ("DOID:0080795", "skos:exactMatch", "EFO:0003029", "semapv:ManualMappingCuration"), ("DOID:0080795", "skos:exactMatch", "mesh:D015471", "semapv:ManualMappingCuration"), ("DOID:0080799", "skos:exactMatch", "EFO:1000527", "semapv:ManualMappingCuration"), ( "DOID:0080808", "skos:exactMatch", "mesh:D000069295", "semapv:ManualMappingCuration", ), ] df = pd.DataFrame( rows, columns=["subject_id", "predicate_id", "object_id", "mapping_justification"] ) idx = get_filter_df_by_prefixes_index(df, column="object_id", prefixes=["EFO"]) filtered_df = df[idx]