morpheus.utils.compare_df#
Functions
|
Compares two pandas Dataframe, returning a comparison summary as a dict in the form of. |
|
Filters the dataframe |
- compare_df(
- df_a,
- df_b,
- include_columns=None,
- exclude_columns=None,
- replace_idx=None,
- abs_tol=0.001,
- rel_tol=0.005,
- dfa_name='val',
- dfb_name='res',
- show_report=False,
Compares two pandas Dataframe, returning a comparison summary as a dict in the form of:
{ "total_rows": <int>, "matching_rows": <int>, "diff_rows": <int>, "matching_cols": <[str]>, "extra_cols": extra_cols: <[str]>, "missing_cols": missing_cols: <[str]>, }
- filter_df(df, include_columns, exclude_columns, replace_idx=None)[source]#
Filters the dataframe
dfincluding and excluding the columns specified byinclude_columnsandexclude_columnsrespectively. If a column is matched by bothinclude_columnsandexclude_columns, it will be excluded.- Parameters:
- dfpd.DataFrame
Dataframe to filter.
- include_columnstyping.List[str]
List of regular expression strings of columns to be included.
- exclude_columnstyping.List[str]
List of regular expression strings of columns to be excluded.
- replace_idx: str, optional
When
replace_idxis not None and existsa in the dataframe it will be set as the index.
- Returns:
- pd.DataFrame
Filtered slice of
df.