Skip to content

Commit 9184934

Browse files
committed
docstring update: added more examples for pandas.Series.str.split() method
1 parent 78ded25 commit 9184934

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pandas/core/strings.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -1145,8 +1145,10 @@ def str_split(arr, pat=None, n=None):
11451145
1 [but this is even better]
11461146
dtype: object
11471147
1148-
When using ``expand=True``, the split elements will
1149-
expand out into separate columns.
1148+
When using ``expand=True``, the split elements will expand out into
1149+
separate columns.
1150+
1151+
For Series object, output return type is DataFrame.
11501152
11511153
>>> s.str.split(expand=True)
11521154
0 1 2 3 4
@@ -1157,6 +1159,13 @@ def str_split(arr, pat=None, n=None):
11571159
0 this good text
11581160
1 but this even better
11591161
1162+
For Index object, output return type is MultiIndex.
1163+
1164+
>>> i = pd.Index(["ba 100 001", "ba 101 002", "ba 102 003"])
1165+
>>> i.str.split(expand=True)
1166+
MultiIndex(levels=[['ba'], ['100', '101', '102'], ['001', '002', '003']],
1167+
labels=[[0, 0, 0], [0, 1, 2], [0, 1, 2]])
1168+
11601169
Parameter `n` can be used to limit the number of splits in the output.
11611170
11621171
>>> s.str.split("is", n=1)

0 commit comments

Comments
 (0)