-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix various pandas issues #22705
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 various pandas issues #22705
Changes from all commits
6e179da
6680fc3
96c9450
a84c350
38487ce
513779f
0ab8776
13c6a54
25022e0
e642498
1f0610f
c9d1606
d96081e
0071847
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -335,9 +335,19 @@ def custom_repr_html(obj): | |
|
|
||
|
|
||
| def _Series_dtype(self): | ||
| # Fast-path to extract dtype from the current | ||
| # object without round-tripping through the slow<->fast | ||
| return _maybe_wrap_result(self._fsproxy_wrapped.dtype, None) | ||
| dtype = self._fsproxy_wrapped.dtype | ||
| if isinstance( | ||
| dtype, | ||
| ( | ||
| cudf.ListDtype, | ||
| cudf.StructDtype, | ||
| cudf.Decimal32Dtype, | ||
| cudf.Decimal64Dtype, | ||
| cudf.Decimal128Dtype, | ||
| ), | ||
| ): | ||
| dtype = self._fsproxy_slow.dtype | ||
| return _maybe_wrap_result(dtype, None) | ||
|
Comment on lines
337
to
+350
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid mutating proxy state in At Line 349, Suggested fix def _Series_dtype(self):
dtype = self._fsproxy_wrapped.dtype
if isinstance(
dtype,
(
cudf.ListDtype,
cudf.StructDtype,
cudf.Decimal32Dtype,
cudf.Decimal64Dtype,
cudf.Decimal128Dtype,
),
):
- dtype = self._fsproxy_slow.dtype
+ dtype = self._fsproxy_fast_to_slow().dtype
return _maybe_wrap_result(dtype, None)As per coding guidelines: "Detect unnecessary host-device data transfers and repeated GPU-to-host round-trips in hot paths". 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| _SeriesAtIndexer = make_intermediate_proxy_type( | ||
|
|
@@ -1233,6 +1243,12 @@ def Index__setattr__(self, name, value): | |
| pd.core.window.ewm.ExponentialMovingWindowGroupby, | ||
| ) | ||
|
|
||
| OnlineExponentialMovingWindow = make_intermediate_proxy_type( | ||
| "OnlineExponentialMovingWindow", | ||
| _Unusable, | ||
| pd.core.window.ewm.OnlineExponentialMovingWindow, | ||
| ) | ||
|
|
||
| EWMMeanState = make_intermediate_proxy_type( | ||
| "EWMMeanState", | ||
| _Unusable, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -854,6 +854,24 @@ def test_groupby_apply_series_args(func, args): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_groupby_results_equal(expect, got) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_groupby_apply_series_preserves_multiindex_names(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pdf = pd.DataFrame( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {"value": [1.0, 2.0, 3.0, 4.0]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| index=pd.MultiIndex.from_product([range(2), range(2)]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gdf = cudf.from_pandas(pdf) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| by = np.array([0, 0, 1, 1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect = pdf.groupby(by=by, group_keys=False)["value"].apply( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lambda x: x.cumprod() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| got = gdf.groupby(by=by, group_keys=False)["value"].apply( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lambda x: x.cumprod() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq(expect, got) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+857
to
+873
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strengthen this regression by using explicitly named MultiIndex levels. Right now the test can pass without proving that public MultiIndex names are preserved. Set concrete index level names to assert the intended contract directly. Proposed test tightening def test_groupby_apply_series_preserves_multiindex_names():
pdf = pd.DataFrame(
{"value": [1.0, 2.0, 3.0, 4.0]},
- index=pd.MultiIndex.from_product([range(2), range(2)]),
+ index=pd.MultiIndex.from_product(
+ [range(2), range(2)],
+ names=["outer", "inner"],
+ ),
)As per coding guidelines: " 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @pytest.mark.parametrize("group_keys", [None, True, False]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @pytest.mark.parametrize("by", ["A", ["A", "B"]]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_groupby_group_keys(group_keys, by): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Equality logic ignores interval
closedsemantics.__eq__/__ne__currently compare only endpoints, so intervals with identical bounds but differentclosedvalues can be misclassified as equal. Please includeself.closed == other.closedin the equality predicate (or short-circuit unequal-closedbefore endpoint comparison), and add a regression test for comparing same breaks with differentclosedsettings.As per coding guidelines: "Validate algorithm correctness - detect logic errors producing wrong results, silent data corruption from type coercion, and incorrect null/NA handling (cuDF uses nullable dtypes throughout)".
🤖 Prompt for AI Agents