Skip to content

Commit

Permalink
Merge branch 'str_replace_regex' of https://github.com/Liam3851/pandas
Browse files Browse the repository at this point in the history
into str_replace_regex

# Conflicts:
#	doc/source/whatsnew/v0.23.0.txt
#	pandas/core/strings.py
  • Loading branch information
Liam3851 committed Feb 27, 2018
2 parents 511ecfd + 89979d7 commit 531f59a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ Other API Changes
- Set operations (union, difference...) on :class:`IntervalIndex` with incompatible index types will now raise a ``TypeError`` rather than a ``ValueError`` (:issue:`19329`)
- :class:`DateOffset` objects render more simply, e.g. ``<DateOffset: days=1>`` instead of ``<DateOffset: kwds={'days': 1}>`` (:issue:`19403`)
- ``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`)
- :func:`pandas.merge` provides a more informative error message when trying to merge on timezone-aware and timezone-naive columns (:issue:`15800`)
- :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`)

.. _whatsnew_0230.deprecations:
Expand Down
10 changes: 10 additions & 0 deletions pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,16 @@ def str_replace(arr, pat, repl, n=-1, case=None, flags=0, regex=True):
2 NaN
dtype: object
When `pat` is a string and `regex` is True, the given `pat` is compiled
as a regex. When `repl` is a string, it replaces matching regex patterns
as with :meth:`re.sub`:
>>> pd.Series(['foo', 'fuz', np.nan]).str.replace('f.', 'ba', regex=True)
0 bao
1 baz
2 NaN
dtype: object
When `repl` is a callable, it is called on every `pat` using
:func:`re.sub`. The callable should expect one positional argument
(a regex object) and return a string.
Expand Down

0 comments on commit 531f59a

Please sign in to comment.