@@ -328,19 +328,54 @@ def str_contains(arr, pat, case=True, flags=0, na=np.nan, regex=True):
328
328
329
329
def str_startswith (arr , pat , na = np .nan ):
330
330
"""
331
- Return boolean Series/``array`` indicating whether each string in the
332
- Series/Index starts with passed pattern. Equivalent to
333
- :meth:`str.startswith`.
331
+ Test if the start of each string element matches a pattern.
332
+
333
+ Equivalent to :meth:`str.startswith`.
334
334
335
335
Parameters
336
336
----------
337
- pat : string
338
- Character sequence
339
- na : bool, default NaN
337
+ pat : str
338
+ Character sequence. Regular expressions are not accepted.
339
+ na : object, default NaN
340
+ Object shown if element tested is not a string.
340
341
341
342
Returns
342
343
-------
343
- startswith : Series/array of boolean values
344
+ Series or Index of bool
345
+ A Series of booleans indicating whether the given pattern matches
346
+ the start of each string element.
347
+
348
+ See Also
349
+ --------
350
+ str.startswith : Python standard library string method.
351
+ Series.str.endswith : Same as startswith, but tests the end of string.
352
+ Series.str.contains : Tests if string element contains a pattern.
353
+
354
+ Examples
355
+ --------
356
+ >>> s = pd.Series(['bat', 'Bear', 'cat', np.nan])
357
+ >>> s
358
+ 0 bat
359
+ 1 Bear
360
+ 2 cat
361
+ 3 NaN
362
+ dtype: object
363
+
364
+ >>> s.str.startswith('b')
365
+ 0 True
366
+ 1 False
367
+ 2 False
368
+ 3 NaN
369
+ dtype: object
370
+
371
+ Specifying `na` to be `False` instead of `NaN`.
372
+
373
+ >>> s.str.startswith('b', na=False)
374
+ 0 True
375
+ 1 False
376
+ 2 False
377
+ 3 False
378
+ dtype: bool
344
379
"""
345
380
f = lambda x : x .startswith (pat )
346
381
return _na_map (f , arr , na , dtype = bool )
0 commit comments