Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support at/iat indexers in cudf.pandas #16177

Merged
merged 8 commits into from
Jul 8, 2024
12 changes: 12 additions & 0 deletions python/cudf/cudf/pandas/_wrappers/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,18 @@ def Index__new__(cls, *args, **kwargs):
pd.core.indexing._LocIndexer,
)

_AtIndexer = make_intermediate_proxy_type(
"_AtIndexer",
_Unusable(),
pd.core.indexing._AtIndexer,
)

_iAtIndexer = make_intermediate_proxy_type(
"_iAtIndexer",
_Unusable(),
pd.core.indexing._iAtIndexer,
)

FixedForwardWindowIndexer = make_final_proxy_type(
"FixedForwardWindowIndexer",
_Unusable,
Expand Down
11 changes: 11 additions & 0 deletions python/cudf/cudf_pandas_tests/test_cudf_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1566,3 +1566,14 @@ def test_arrow_string_arrays():
)

tm.assert_equal(cu_arr, pd_arr)


@pytest.mark.parametrize("indexer", ["at", "iat"])
def test_at_iat(indexer):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this cover the case of a new column that doesn't exist? I'd like to see a test that more clearly resembles the patterns in the minimal repro of #16112.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, added a unit test in a43454c to mirror the issue. (It appears that iat.__setitem__ in pandas doesn't support the type of behavior demonstrated in the issue)

Copy link
Contributor Author

@mroeschke mroeschke Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, thanks for encouraging a unit test with the issue. Even though the test passed locally the CI didn't agree.

Left some investigation notes in #16112 (comment) that I may come back to later

df = xpd.DataFrame(range(3))
result = getattr(df, indexer)[0, 0]
assert result == 0

getattr(df, indexer)[0, 0] = 1
expected = pd.DataFrame([1, 1, 2])
tm.assert_frame_equal(df, expected)
Loading