Skip to content

Commit 531f59a

Browse files
committed
Merge branch 'str_replace_regex' of https://github.com/Liam3851/pandas
into str_replace_regex # Conflicts: # doc/source/whatsnew/v0.23.0.txt # pandas/core/strings.py
2 parents 511ecfd + 89979d7 commit 531f59a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

doc/source/whatsnew/v0.23.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ Other API Changes
620620
- Set operations (union, difference...) on :class:`IntervalIndex` with incompatible index types will now raise a ``TypeError`` rather than a ``ValueError`` (:issue:`19329`)
621621
- :class:`DateOffset` objects render more simply, e.g. ``<DateOffset: days=1>`` instead of ``<DateOffset: kwds={'days': 1}>`` (:issue:`19403`)
622622
- ``Categorical.fillna`` now validates its ``value`` and ``method`` keyword arguments. It now raises when both or none are specified, matching the behavior of :meth:`Series.fillna` (:issue:`19682`)
623+
- :func:`pandas.merge` provides a more informative error message when trying to merge on timezone-aware and timezone-naive columns (:issue:`15800`)
623624
- :func:`Series.str.replace` now takes an optional `regex` keyword which, when set to ``False``, uses literal string replacement rather than regex replacement (:issue:`16808`)
624625

625626
.. _whatsnew_0230.deprecations:

pandas/core/strings.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,16 @@ def str_replace(arr, pat, repl, n=-1, case=None, flags=0, regex=True):
376376
2 NaN
377377
dtype: object
378378
379+
When `pat` is a string and `regex` is True, the given `pat` is compiled
380+
as a regex. When `repl` is a string, it replaces matching regex patterns
381+
as with :meth:`re.sub`:
382+
383+
>>> pd.Series(['foo', 'fuz', np.nan]).str.replace('f.', 'ba', regex=True)
384+
0 bao
385+
1 baz
386+
2 NaN
387+
dtype: object
388+
379389
When `repl` is a callable, it is called on every `pat` using
380390
:func:`re.sub`. The callable should expect one positional argument
381391
(a regex object) and return a string.

0 commit comments

Comments
 (0)