bundles / numpy 2.4.4 / numpy / strings / count
function
numpy.strings:count
source: /numpy/_core/strings.py :404
Signature
def count ( a , sub , start = 0 , end = None ) Summary
Returns an array with the number of non-overlapping occurrences of substring sub in the range [start, end).
Parameters
a: array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtypesub: array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtypeThe substring to search for.
start, end: array_like, with any integer dtypeThe range to look in, interpreted as in slice notation.
Returns
y: ndarrayOutput array of ints
Examples
import numpy as np c = np.array(['aAaAaA', ' aA ', 'abBABba']) c np.strings.count(c, 'A') np.strings.count(c, 'aA') np.strings.count(c, 'A', start=1, end=4) np.strings.count(c, 'A', start=1, end=3)✓
See also
- str.count
Aliases
-
numpy.char.count