From ceb29a8342f2a0d1f4c5519e99bc233a604136b4 Mon Sep 17 00:00:00 2001 From: Vandenn Date: Thu, 2 May 2019 23:21:32 +0800 Subject: [PATCH] DOC: Add regex example in str.split docstring --- pandas/core/strings.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pandas/core/strings.py b/pandas/core/strings.py index f78997a506f94..84927a149023a 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -2255,7 +2255,7 @@ def cat(self, others=None, sep=None, na_rep=None, join=None): name=self._orig.name) return result - _shared_docs['str_split'] = (""" + _shared_docs['str_split'] = (r""" Split strings around given separator/delimiter. Splits the string in the Series/Index from the %(side)s, @@ -2370,6 +2370,15 @@ def cat(self, others=None, sep=None, na_rep=None, join=None): 0 this is a regular sentence None 1 https://docs.python.org/3/tutorial index.html 2 NaN NaN + + Remember to escape special characters when explicitly using regular + expressions. + + >>> s = pd.Series(["1+1=2"]) + + >>> s.str.split(r"\+|=", expand=True) + 0 1 2 + 0 1 1 2 """) @Appender(_shared_docs['str_split'] % {