Skip to content

omnipy.components.pandas.helpers

Helpers for working with pandas-backed Omnipy datasets.

FUNCTION DESCRIPTION
extract_common_colnames

Return column names shared by two pandas-compatible tables.

extract_common_colnames

extract_common_colnames(df_1: PandasModel | pd.DataFrame, df_2: PandasModel | pd.DataFrame)

Return column names shared by two pandas-compatible tables.

Source code in src/omnipy/components/pandas/helpers.py
def extract_common_colnames(df_1: 'PandasModel | pd.DataFrame', df_2: 'PandasModel | pd.DataFrame'):
    """Return column names shared by two pandas-compatible tables."""

    common_colnames_set = set(df_1.columns) & set(df_2.columns)
    common_colnames = tuple(col for col in df_1.columns if col in common_colnames_set)
    return common_colnames