Skip to content

fix: make Series.str.replace work for simple strings #285

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

Merged
merged 1 commit into from
Dec 21, 2023
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
2 changes: 1 addition & 1 deletion bigframes/operations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def _as_ibis(self, x: ibis_types.Value):
ibis_types.StringValue, ibis_types.literal(self._pat)
)
repl_str_value = typing.cast(
ibis_types.StringValue, ibis_types.literal(self._pat)
ibis_types.StringValue, ibis_types.literal(self._repl)
)

return typing.cast(ibis_types.StringValue, x).replace(
Expand Down
2 changes: 2 additions & 0 deletions tests/system/small/operations/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def test_str_extract(scalars_dfs, pat):
(".*", "blah", True, 0, True),
("h.l", "blah", False, 0, True),
(re.compile("(?i).e.."), "blah", None, 0, True),
("H", "h", True, 0, False),
(", ", "__", True, 0, False),
],
)
def test_str_replace(scalars_dfs, pat, repl, case, flags, regex):
Expand Down
18 changes: 18 additions & 0 deletions third_party/bigframes_vendored/pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2304,6 +2304,24 @@ def str(self):
NAs stay NA unless handled otherwise by a particular method. Patterned
after Python’s string methods, with some inspiration from R’s stringr package.

**Examples:**

>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None

>>> s = bpd.Series(["A_Str_Series"])
>>> s
0 A_Str_Series
dtype: string

>>> s.str.lower()
0 a_str_series
dtype: string

>>> s.str.replace("_", "")
0 AStrSeries
dtype: string

Returns:
bigframes.operations.strings.StringMethods:
An accessor containing string methods.
Expand Down