Skip to content

Commit

Permalink
SNOW-1355199: Fix incorrect regex used in DataFrame/Series.replace
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-helmeleegy committed Apr 29, 2024
1 parent 88a5697 commit 4839722
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
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 @@ -4,6 +4,7 @@
- Fixed overriding of subclasses' property docstrings for modin issue https://github.com/modin-project/modin/issues/7113.
- Fixed `@udf` decorator when `packages=None` are specified preventing error in `Series.apply`.
- Fixed incorrect regex used in `Series.str.contains`.
- 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

0 comments on commit 4839722

Please sign in to comment.