Skip to content

Commit e854ccf

Browse files
vandenngfyoung
authored andcommitted
DOC: Add regex example in str.split docstring (#26267)
Closes gh-25296
1 parent 0989339 commit e854ccf

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pandas/core/strings.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,7 @@ def cat(self, others=None, sep=None, na_rep=None, join=None):
22552255
name=self._orig.name)
22562256
return result
22572257

2258-
_shared_docs['str_split'] = ("""
2258+
_shared_docs['str_split'] = (r"""
22592259
Split strings around given separator/delimiter.
22602260
22612261
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):
23702370
0 this is a regular sentence None
23712371
1 https://docs.python.org/3/tutorial index.html
23722372
2 NaN NaN
2373+
2374+
Remember to escape special characters when explicitly using regular
2375+
expressions.
2376+
2377+
>>> s = pd.Series(["1+1=2"])
2378+
2379+
>>> s.str.split(r"\+|=", expand=True)
2380+
0 1 2
2381+
0 1 1 2
23732382
""")
23742383

23752384
@Appender(_shared_docs['str_split'] % {

0 commit comments

Comments
 (0)