MCPcopy
hub / github.com/ray-project/ray / rows_same

Function rows_same

python/ray/data/_internal/util.py:1886–1904  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1884
1885
1886def 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
1907def merge_resources_to_ray_remote_args(

Calls 1

_sort_dfFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…