Skip to content

Commit f07c0a7

Browse files
committed
DOC: Add regex example in str.split docstring
1 parent d49ebd4 commit f07c0a7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/core/strings.py

+10
Original file line numberDiff line numberDiff line change
@@ -2370,6 +2370,16 @@ 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", np.nan])
2378+
2379+
>>> s.str.split(r"\+|=", expand=True)
2380+
0 1 2
2381+
0 1 1 2
2382+
1 NaN NaN NaN
23732383
""")
23742384

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

0 commit comments

Comments
 (0)