@@ -1095,24 +1095,48 @@ def str_pad(arr, width, side='left', fillchar=' '):
10951095
10961096def str_split (arr , pat = None , n = None ):
10971097 """
1098+ Split strings around given separator/delimiter.
1099+
10981100 Split each string (a la re.split) in the Series/Index by given
10991101 pattern, propagating NA values. Equivalent to :meth:`str.split`.
11001102
11011103 Parameters
11021104 ----------
11031105 pat : string, default None
1104- String or regular expression to split on. If None, splits on whitespace
1106+ String or regular expression to split on. If None, split on whitespace.
11051107 n : int, default -1 (all)
1106- None, 0 and -1 will be interpreted as return all splits
1108+ * None, 0 and -1 will be interpreted as return all splits.
1109+ * Vary output dimensionality if `expand` is True:
1110+ - If n >= default splits, return all splits.
1111+ - If n < default splits, makes first n splits only.
11071112 expand : bool, default False
1108- * If True, return DataFrame/MultiIndex expanding dimensionality.
1113+ * If True, return DataFrame/MultiIndex expanding dimensionality.\
1114+ Appends None for padding.
11091115 * If False, return Series/Index.
11101116
1111- return_type : deprecated, use `expand`
1112-
11131117 Returns
11141118 -------
11151119 split : Series/Index or DataFrame/MultiIndex of objects
1120+
1121+ Examples
1122+ --------
1123+ >>> s = pd.Series(["this is good text", "but this is even better"])
1124+ >>> s.str.split()
1125+ 0 [this, is, good, text]
1126+ 1 [but, this, is, even, better]
1127+ dtype: object
1128+ >>> s.str.split(expand=True)
1129+ 0 1 2 3 4
1130+ 0 this is good text None
1131+ 1 but this is even better
1132+ >>> s.str.split(" is ", expand=True)
1133+ 0 1
1134+ 0 this good text
1135+ 1 but this even better
1136+ >>> s.str.split("is", n=1, expand=True)
1137+ 0 1
1138+ 0 th is good text
1139+ 1 but th is even better
11161140 """
11171141 if pat is None :
11181142 if n is None or n == 0 :
0 commit comments