Skip to content

Commit f4b7d7c

Browse files
committed
Review datapythonista for file text.rst
Signed-off-by: Fabian Haase <[email protected]>
1 parent 996d529 commit f4b7d7c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

doc/source/text.rst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,18 @@ positional argument (a regex object) and return a string.
168168
169169
# Reverse every lowercase alphabetic word
170170
pat = r'[a-z]+'
171-
repl = lambda m: m.group(0)[::-1] # noqa: E731
171+
172+
def repl(m):
173+
return m.group(0)[::-1]
174+
172175
pd.Series(['foo 123', 'bar baz', np.nan]).str.replace(pat, repl)
173176
174177
# Using regex groups
175178
pat = r"(?P<one>\w+) (?P<two>\w+) (?P<three>\w+)"
176-
repl = lambda m: m.group('two').swapcase() # noqa: E731
179+
180+
def repl(m):
181+
return m.group('two').swapcase()
182+
177183
pd.Series(['Foo Bar Baz', np.nan]).str.replace(pat, repl)
178184
179185
.. versionadded:: 0.20.0
@@ -191,12 +197,11 @@ compiled regular expression object.
191197
Including a ``flags`` argument when calling ``replace`` with a compiled
192198
regular expression object will raise a ``ValueError``.
193199

194-
.. ipython::
200+
.. ipython:: ipython
201+
:verbatim:
195202

196-
@verbatim
197203
In [1]: s3.str.replace(regex_pat, 'XX-XX ', flags=re.IGNORECASE)
198-
---------------------------------------------------------------------------
199-
ValueError: case and flags cannot be set when pat is a compiled regex
204+
Out[1]: ValueError: case and flags cannot be set when pat is a compiled regex
200205

201206
.. _text.concatenate:
202207

0 commit comments

Comments
 (0)