@@ -1118,7 +1118,7 @@ def str_split(arr, pat=None, n=None):
1118
1118
-------
1119
1119
split : Series/Index or DataFrame/MultiIndex of objects
1120
1120
Type matches caller unless ``expand=True`` (return type is DataFrame or
1121
- MultiIndex)
1121
+ MultiIndex)
1122
1122
1123
1123
Notes
1124
1124
-----
@@ -1145,8 +1145,10 @@ def str_split(arr, pat=None, n=None):
1145
1145
1 [but this is even better]
1146
1146
dtype: object
1147
1147
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.
1150
1152
1151
1153
>>> s.str.split(expand=True)
1152
1154
0 1 2 3 4
@@ -1157,6 +1159,13 @@ def str_split(arr, pat=None, n=None):
1157
1159
0 this good text
1158
1160
1 but this even better
1159
1161
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
+
1160
1169
Parameter `n` can be used to limit the number of splits in the output.
1161
1170
1162
1171
>>> s.str.split("is", n=1)
0 commit comments