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-1355199: Fix incorrect regex used in DataFrame/Series.replace #1453

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 src/snowflake/snowpark/modin/plugin/PANDAS_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Fixed `@udf` decorator when `packages=None` are specified preventing error in `Series.apply`.
- Fixed incorrect regex used in `Series.str.contains`.
- Fixed DataFrame's `__getitem__` with boolean DataFrame key.
- Fixed incorrect regex used in `DataFrame/Series.replace`.

## 1.14.0a2 (2024-04-18)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10395,7 +10395,7 @@ def replace(
if native_pd.isna(k):
cond = column.is_null()
elif regex is True:
cond = column.regexp(pandas_lit(k))
cond = column.regexp(pandas_lit(f".*{k}.*"))
v = regexp_replace(subject=column, pattern=k, replacement=v)
else:
cond = column == k
Expand Down
3 changes: 3 additions & 0 deletions tests/integ/modin/frame/test_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def snow_df():
"to_replace, value",
[
("one", "ONE"), # scalar -> scalar
("on", "ON"), # scalar prefix-> scalar
("ne", "NE"), # scalar suffix-> scalar
("n", "N"), # scalar infix-> scalar
("one", pd.NA), # scalar -> NULL
("one", None), # scalar -> None
(pd.NA, "ONE"), # NULL -> scalar
Expand Down
3 changes: 3 additions & 0 deletions tests/integ/modin/series/test_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def snow_series():
"to_replace, value",
[
("one", "ONE"), # scalar -> scalar
("on", "ON"), # scalar prefix-> scalar
("ne", "NE"), # scalar suffix-> scalar
("n", "N"), # scalar infix-> scalar
("one", pd.NA), # scalar -> NULL
("one", None), # scalar -> None
(pd.NA, "ONE"), # NULL -> scalar
Expand Down
Loading