Check if two DataFrames have the same rows. Unlike the built-in pandas equals method, this function ignores indices and the order of rows. This is useful for testing Ray Data because its interface doesn't usually guarantee the order of rows.
(actual: pd.DataFrame, expected: pd.DataFrame)
| 1884 | |
| 1885 | |
| 1886 | def rows_same(actual: pd.DataFrame, expected: pd.DataFrame) -> bool: |
| 1887 | """Check if two DataFrames have the same rows. |
| 1888 | |
| 1889 | Unlike the built-in pandas equals method, this function ignores indices and the |
| 1890 | order of rows. This is useful for testing Ray Data because its interface doesn't |
| 1891 | usually guarantee the order of rows. |
| 1892 | """ |
| 1893 | if len(actual) != len(expected): |
| 1894 | return False |
| 1895 | |
| 1896 | if len(actual) == 0: |
| 1897 | return True |
| 1898 | |
| 1899 | pd.testing.assert_frame_equal( |
| 1900 | _sort_df(actual).reset_index(drop=True), |
| 1901 | _sort_df(expected).reset_index(drop=True), |
| 1902 | check_dtype=False, |
| 1903 | ) |
| 1904 | return True |
| 1905 | |
| 1906 | |
| 1907 | def merge_resources_to_ray_remote_args( |
searching dependent graphs…