numpy.core.defchararray.count(a, sub, start=0, end=None)
[source]
Returns an array with the number of non-overlapping occurrences of substring sub
in the range [start
, end
].
Calls str.count
element-wise.
Parameters: |
a : array_like of str or unicode sub : str or unicode The substring to search for. start, end : int, optional Optional arguments |
---|---|
Returns: |
out : ndarray Output array of ints. |
See also
>>> c = np.array(['aAaAaA', ' aA ', 'abBABba']) >>> c array(['aAaAaA', ' aA ', 'abBABba'], dtype='|S7') >>> np.char.count(c, 'A') array([3, 1, 1]) >>> np.char.count(c, 'aA') array([3, 1, 0]) >>> np.char.count(c, 'A', start=1, end=4) array([2, 1, 1]) >>> np.char.count(c, 'A', start=1, end=3) array([1, 0, 0])
© 2008–2017 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.12.0/reference/generated/numpy.core.defchararray.count.html