@@ -2243,9 +2243,8 @@ def cat(self, others=None, sep=None, na_rep=None, join=None):
2243
2243
_shared_docs ['str_split' ] = ("""
2244
2244
Split strings around given separator/delimiter.
2245
2245
2246
- Returns a list of the words from each string in Series/Index,
2247
- split by the given delimiter string, starting at the %(side)s of the
2248
- string. Equivalent to :meth:`str.%(method)s`.
2246
+ Splits the string in the Series/Index from the %(side)s,
2247
+ at the specified delimiter string.Equivalent to :meth:`str.%(method)s`.
2249
2248
2250
2249
Parameters
2251
2250
----------
@@ -2284,31 +2283,29 @@ def cat(self, others=None, sep=None, na_rep=None, join=None):
2284
2283
2285
2284
Examples
2286
2285
--------
2287
- >>> s = pd.Series(["this is good text", "but this is even better"])
2286
+ %(example)s
2287
+ """ )
2288
2288
2289
- By default, split and rsplit will return an object of the same size
2289
+ @Appender (_shared_docs ['str_split' ] % {
2290
+ 'side' :'beginning' ,
2291
+ 'method' :'split' ,
2292
+ 'also' : 'rsplit : Split the string at the last occurrence of delimiter' ,
2293
+ 'example' :
2294
+ """>>> s = pd.Series(["this is good text", "but this is even better"])
2295
+
2296
+ By default, split will return an object of the same size
2290
2297
having lists containing the split elements
2291
2298
2292
2299
>>> s.str.split()
2293
2300
0 [this, is, good, text]
2294
2301
1 [but, this, is, even, better]
2295
- dtype: object
2296
-
2297
- >>> s.str.rsplit()
2298
- 0 [this, is, good, text]
2299
- 1 [but, this, is, even, better]
2300
2302
dtype: object
2301
2303
2302
2304
>>> s.str.split("random")
2303
2305
0 [this is good text]
2304
2306
1 [but this is even better]
2305
2307
dtype: object
2306
2308
2307
- >>> s.str.rsplit("random")
2308
- 0 [this is good text]
2309
- 1 [but this is even better]
2310
- dtype: object
2311
-
2312
2309
When using ``expand=True``, the split and rsplit elements will
2313
2310
expand out into separate columns.
2314
2311
@@ -2331,11 +2328,6 @@ def cat(self, others=None, sep=None, na_rep=None, join=None):
2331
2328
1 [but th, is even better]
2332
2329
dtype: object
2333
2330
2334
- >>> s.str.rsplit("is", n=1)
2335
- 0 [this , good text]
2336
- 1 [but this , even better]
2337
- dtype: object
2338
-
2339
2331
If NaN is present, it is propagated throughout the columns
2340
2332
during the split.
2341
2333
@@ -2345,23 +2337,48 @@ def cat(self, others=None, sep=None, na_rep=None, join=None):
2345
2337
0 1 2 3
2346
2338
0 this is good text
2347
2339
1 but this is even better
2348
- 2 NaN NaN NaN NaN
2340
+ 2 NaN NaN NaN NaN """ })
2341
+ def split (self , pat = None , n = - 1 , expand = False ):
2342
+ result = str_split (self ._data , pat , n = n )
2343
+ return self ._wrap_result (result , expand = expand )
2344
+
2345
+ @Appender (_shared_docs ['str_split' ] % {
2346
+ 'side' :'end' ,
2347
+ 'method' :'rsplit' ,
2348
+ 'also' : 'split : Split the string at the first occurrence of delimiter' ,
2349
+ 'example' :
2350
+ """>>> s = pd.Series(["this is good text", "but this is even better"])
2351
+
2352
+ By default, rsplit will return an object of the same size
2353
+ having lists containing the split elements
2354
+
2355
+ >>> s.str.rsplit()
2356
+ 0 [this, is, good, text]
2357
+ 1 [but, this, is, even, better]
2358
+ dtype: object
2359
+
2360
+ >>> s.str.rsplit("random")
2361
+ 0 [this is good text]
2362
+ 1 [but this is even better]
2363
+ dtype: object
2364
+
2365
+ Parameter `n` can be used to limit the number of splits in the output.
2366
+
2367
+ >>> s.str.rsplit("is", n=1)
2368
+ 0 [this , good text]
2369
+ 1 [but this , even better]
2370
+ dtype: object
2371
+
2372
+ If NaN is present, it is propagated throughout the columns
2373
+ during the split.
2374
+
2375
+ >>> s = pd.Series(["this is good text", "but this is even better", np.nan])
2349
2376
2350
2377
>>> s.str.rsplit(n=3, expand=True)
2351
2378
0 1 2 3
2352
2379
0 this is good text
2353
2380
1 but this is even better
2354
- 2 NaN NaN NaN NaN
2355
- """ )
2356
-
2357
- @Appender (_shared_docs ['str_split' ] % dict (side = 'start' ,
2358
- method = 'split' ))
2359
- def split (self , pat = None , n = - 1 , expand = False ):
2360
- result = str_split (self ._data , pat , n = n )
2361
- return self ._wrap_result (result , expand = expand )
2362
-
2363
- @Appender (_shared_docs ['str_split' ] % dict (side = 'end' ,
2364
- method = 'rsplit' ))
2381
+ 2 NaN NaN NaN NaN """ })
2365
2382
def rsplit (self , pat = None , n = - 1 , expand = False ):
2366
2383
result = str_rsplit (self ._data , pat , n = n )
2367
2384
return self ._wrap_result (result , expand = expand )
0 commit comments