Check that left and right DataFrame are equal. This function is intended to compare two DataFrames and output any differences. It is mostly intended for use in unit tests. Additional parameters allow varying the strictness of the equality checks performed. Parameters -
(
left,
right,
check_dtype: bool | Literal["equiv"] = True,
check_index_type: bool | Literal["equiv"] = "equiv",
check_column_type: bool | Literal["equiv"] = "equiv",
check_frame_type: bool = True,
check_names: bool = True,
by_blocks: bool = False,
check_exact: bool | lib.NoDefault = lib.no_default,
check_datetimelike_compat: bool = False,
check_categorical: bool = True,
check_like: bool = False,
check_freq: bool = True,
check_flags: bool = True,
rtol: float | lib.NoDefault = lib.no_default,
atol: float | lib.NoDefault = lib.no_default,
obj: str = "DataFrame",
)
| 1148 | @set_module("pandas.testing") |
| 1149 | @deprecate_kwarg(Pandas4Warning, "check_datetimelike_compat", new_arg_name=None) |
| 1150 | def assert_frame_equal( |
| 1151 | left, |
| 1152 | right, |
| 1153 | check_dtype: bool | Literal["equiv"] = True, |
| 1154 | check_index_type: bool | Literal["equiv"] = "equiv", |
| 1155 | check_column_type: bool | Literal["equiv"] = "equiv", |
| 1156 | check_frame_type: bool = True, |
| 1157 | check_names: bool = True, |
| 1158 | by_blocks: bool = False, |
| 1159 | check_exact: bool | lib.NoDefault = lib.no_default, |
| 1160 | check_datetimelike_compat: bool = False, |
| 1161 | check_categorical: bool = True, |
| 1162 | check_like: bool = False, |
| 1163 | check_freq: bool = True, |
| 1164 | check_flags: bool = True, |
| 1165 | rtol: float | lib.NoDefault = lib.no_default, |
| 1166 | atol: float | lib.NoDefault = lib.no_default, |
| 1167 | obj: str = "DataFrame", |
| 1168 | ) -> None: |
| 1169 | """ |
| 1170 | Check that left and right DataFrame are equal. |
| 1171 | |
| 1172 | This function is intended to compare two DataFrames and output any |
| 1173 | differences. It is mostly intended for use in unit tests. |
| 1174 | Additional parameters allow varying the strictness of the |
| 1175 | equality checks performed. |
| 1176 | |
| 1177 | Parameters |
| 1178 | ---------- |
| 1179 | left : DataFrame |
| 1180 | First DataFrame to compare. |
| 1181 | right : DataFrame |
| 1182 | Second DataFrame to compare. |
| 1183 | check_dtype : bool, default True |
| 1184 | Whether to check the DataFrame dtype is identical. |
| 1185 | check_index_type : bool or {'equiv'}, default 'equiv' |
| 1186 | Whether to check the Index class, dtype and inferred_type |
| 1187 | are identical. |
| 1188 | check_column_type : bool or {'equiv'}, default 'equiv' |
| 1189 | Whether to check the columns class, dtype and inferred_type |
| 1190 | are identical. Is passed as the ``exact`` argument of |
| 1191 | :func:`assert_index_equal`. |
| 1192 | check_frame_type : bool, default True |
| 1193 | Whether to check the DataFrame class is identical. |
| 1194 | check_names : bool, default True |
| 1195 | Whether to check that the `names` attribute for both the `index` |
| 1196 | and `column` attributes of the DataFrame is identical. |
| 1197 | by_blocks : bool, default False |
| 1198 | Specify how to compare internal data. If False, compare by columns. |
| 1199 | If True, compare by blocks. |
| 1200 | check_exact : bool, default False |
| 1201 | Whether to compare number exactly. If False, the comparison uses the |
| 1202 | relative tolerance (``rtol``) and absolute tolerance (``atol``) |
| 1203 | parameters to determine if two values are considered close, |
| 1204 | according to the formula: ``|a - b| <= (atol + rtol * |b|)``. |
| 1205 | |
| 1206 | .. versionchanged:: 2.2.0 |
| 1207 |
no test coverage detected