Skip to content

Commit

Permalink
fix: make Series.str.replace work for simple strings (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
shobsi authored Dec 21, 2023
1 parent 95b673a commit ad67465
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
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

0 comments on commit ad67465

Please sign in to comment.