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

Fix Dataframe.__setitem__ slow-downs #17222

Merged
merged 15 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix and add tests
  • Loading branch information
galipremsagar committed Nov 8, 2024
commit c3debb56e8236be26c3343056c55e4fe7e4f5034
1 change: 1 addition & 0 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,7 @@ dependencies:
# installation issues with `psycopg2`.
- pandas[test, pyarrow, performance, computation, fss, excel, parquet, feather, hdf5, spss, html, xml, plot, output-formatting, clipboard, compression]
- pytest-reportlog
- pytest-timeout
- ipython
test_python_cudf_pandas:
common:
Expand Down
18 changes: 18 additions & 0 deletions python/cudf/cudf_pandas_tests/test_cudf_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1795,3 +1795,21 @@ def test_iter_doesnot_raise(monkeypatch):
monkeycontext.setenv("CUDF_PANDAS_FAIL_ON_FALLBACK", "True")
for _ in s:
pass


@pytest.mark.timeout(5)
galipremsagar marked this conversation as resolved.
Show resolved Hide resolved
def test_dataframe_setitem_slowdown():
# We are explictily testing the slowdown of the setitem operation
Copy link
Contributor

Choose a reason for hiding this comment

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

Please give another sentence or two about how this works. Specifically, that we expect the input transformation to be skipped.

Suggested change
# We are explictily testing the slowdown of the setitem operation
# We are explicitly testing the slowdown of the setitem operation.

df = xpd.DataFrame(
{"a": [1, 2, 3] * 100000, "b": [1, 2, 3] * 100000}
).astype("float64")
df = xpd.DataFrame({"a": df["a"].repeat(1000), "b": df["b"].repeat(1000)})
new_df = df + 1
df[df.columns] = new_df
Matt711 marked this conversation as resolved.
Show resolved Hide resolved


def test_dataframe_setitem():
df = xpd.DataFrame({"a": [1, 2, 3], "b": [1, 2, 3]}).astype("float64")
new_df = df + 1
df[df.columns] = new_df
tm.assert_equal(df, new_df)
1 change: 1 addition & 0 deletions python/cudf/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pandas-tests = [
"ipython",
"pandas[test, pyarrow, performance, computation, fss, excel, parquet, feather, hdf5, spss, html, xml, plot, output-formatting, clipboard, compression]",
"pytest-reportlog",
"pytest-timeout",
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
cudf-pandas-tests = [
"ipython",
Expand Down
Loading