allensdk.core.dataframe_utils module

allensdk.core.dataframe_utils.patch_df_from_other(target_df: pandas.core.frame.DataFrame, source_df: pandas.core.frame.DataFrame, columns_to_patch: List[str], index_column: str) → pandas.core.frame.DataFrame[source]

Overwrite column values in target_df from column values in source_df in rows where the two dataframes share a value of index_column.

Parameters:
target_df: pd.DataFrame

The dataframe whose columns will get overwritten

source_df: pd.DataFrame

The dataframe from which correct values are to be read

columns_to_patch: List[str]

The columns to be overwritten

index_column: str

The column to join the dataframes on

Returns:
patched_df: pd.DataFrame

target_df except with the specified columns and rows overwritten.

Notes

If any of the columns_to_patch are not in target_df, they will be added.

This function starts by creating a copy of target_df, so it will not alter the argument in-place.