@@ -383,19 +383,54 @@ def str_startswith(arr, pat, na=np.nan):
383
383
384
384
def str_endswith (arr , pat , na = np .nan ):
385
385
"""
386
- Return boolean Series indicating whether each string in the
387
- Series/Index ends with passed pattern. Equivalent to
388
- :meth:`str.endswith`.
386
+ Test if the end of each string element matches a pattern.
387
+
388
+ Equivalent to :meth:`str.endswith`.
389
389
390
390
Parameters
391
391
----------
392
- pat : string
393
- Character sequence
394
- na : bool, default NaN
392
+ pat : str
393
+ Character sequence. Regular expressions are not accepted.
394
+ na : object, default NaN
395
+ Object shown if element tested is not a string.
395
396
396
397
Returns
397
398
-------
398
- endswith : Series/array of boolean values
399
+ Series or Index of bool
400
+ A Series of booleans indicating whether the given pattern matches
401
+ the end of each string element.
402
+
403
+ See Also
404
+ --------
405
+ str.endswith : Python standard library string method.
406
+ Series.str.startswith : Same as endswith, but tests the start of string.
407
+ Series.str.contains : Tests if string element contains a pattern.
408
+
409
+ Examples
410
+ --------
411
+ >>> s = pd.Series(['bat', 'bear', 'caT', np.nan])
412
+ >>> s
413
+ 0 bat
414
+ 1 bear
415
+ 2 caT
416
+ 3 NaN
417
+ dtype: object
418
+
419
+ >>> s.str.endswith('t')
420
+ 0 True
421
+ 1 False
422
+ 2 False
423
+ 3 NaN
424
+ dtype: object
425
+
426
+ Specifying `na` to be `False` instead of `NaN`.
427
+
428
+ >>> s.str.endswith('t', na=False)
429
+ 0 True
430
+ 1 False
431
+ 2 False
432
+ 3 False
433
+ dtype: bool
399
434
"""
400
435
f = lambda x : x .endswith (pat )
401
436
return _na_map (f , arr , na , dtype = bool )
0 commit comments