Skip to content

Commit ad67465

Browse files
authored
fix: make Series.str.replace work for simple strings (#285)
1 parent 95b673a commit ad67465

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

bigframes/operations/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def _as_ibis(self, x: ibis_types.Value):
385385
ibis_types.StringValue, ibis_types.literal(self._pat)
386386
)
387387
repl_str_value = typing.cast(
388-
ibis_types.StringValue, ibis_types.literal(self._pat)
388+
ibis_types.StringValue, ibis_types.literal(self._repl)
389389
)
390390

391391
return typing.cast(ibis_types.StringValue, x).replace(

tests/system/small/operations/test_strings.py

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ def test_str_extract(scalars_dfs, pat):
9494
(".*", "blah", True, 0, True),
9595
("h.l", "blah", False, 0, True),
9696
(re.compile("(?i).e.."), "blah", None, 0, True),
97+
("H", "h", True, 0, False),
98+
(", ", "__", True, 0, False),
9799
],
98100
)
99101
def test_str_replace(scalars_dfs, pat, repl, case, flags, regex):

third_party/bigframes_vendored/pandas/core/series.py

+18
Original file line numberDiff line numberDiff line change
@@ -2304,6 +2304,24 @@ def str(self):
23042304
NAs stay NA unless handled otherwise by a particular method. Patterned
23052305
after Python’s string methods, with some inspiration from R’s stringr package.
23062306
2307+
**Examples:**
2308+
2309+
>>> import bigframes.pandas as bpd
2310+
>>> bpd.options.display.progress_bar = None
2311+
2312+
>>> s = bpd.Series(["A_Str_Series"])
2313+
>>> s
2314+
0 A_Str_Series
2315+
dtype: string
2316+
2317+
>>> s.str.lower()
2318+
0 a_str_series
2319+
dtype: string
2320+
2321+
>>> s.str.replace("_", "")
2322+
0 AStrSeries
2323+
dtype: string
2324+
23072325
Returns:
23082326
bigframes.operations.strings.StringMethods:
23092327
An accessor containing string methods.

0 commit comments

Comments
 (0)