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

SNOW-1356685: Fix precision loss bug in DataFrame/Series with dtype=np.uint64 #1777

Merged
merged 3 commits into from
Jun 20, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
- Fixed a bug that causes output of GroupBy.aggregate's columns to be ordered incorrectly.
- Fixed a bug where `DataFrame.describe` on a frame with duplicate columns of differing dtypes could cause an error or incorrect results.
- Fixed a bug in `DataFrame.rolling` and `Series.rolling` so `window=0` now throws `NotImplementedError` instead of `ValueError`
- Fixes a bug in `DataFrame` and `Series` with `dtype=np.uint64` resulting in precision errors
sfc-gh-nkrishna marked this conversation as resolved.
Show resolved Hide resolved

#### Improvements

Expand Down
3 changes: 2 additions & 1 deletion src/snowflake/snowpark/_internal/server_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,9 @@ def _fix_pandas_df_fixed_type(
try:
pd_df[pandas_col_name] = pd_df[pandas_col_name].astype("int64")
except OverflowError:
# Return the original input even if pandas.to_numeric errors
pd_df[pandas_col_name] = pandas.to_numeric(
pd_df[pandas_col_name], downcast="integer"
pd_df[pandas_col_name], errors="ignore"
)
else:
pd_df[pandas_col_name] = pandas.to_numeric(
Expand Down
7 changes: 4 additions & 3 deletions tests/integ/modin/series/test_unique.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ def _make_nan_interleaved_float_series():
[12.0, 11.999999, 11.999999],
["A", "A", "C", "C", "A"],
[None, "A", None, "B"],
_make_nan_interleaved_float_series(),
native_pd.Series([1, 2, 2**63, 2**63], dtype=np.uint64),
pytest.param(
native_pd.Series([1, 2, 2**63, 2**63], dtype=np.uint64),
native_pd.Series([1, 2, -(2**63) - 1, -(2**64)]),
marks=pytest.mark.xfail(
reason="SNOW-1356685: Dtype with unsigned int results in precision error"
reason="Represent overflow using float instead of integer",
),
),
_make_nan_interleaved_float_series(),
]


Expand Down
Loading