numpy.count() in Python Last Updated : 10 Oct, 2019 Comments Improve Suggest changes Like Article Like Report numpy.core.defchararray.count(arr, substring, start=0, end=None): Counts for the non-overlapping occurrence of sub-string in the specified range. Parameters: arr : array-like or string to be searched. substring : substring to search for. start, end : [int, optional] Range to search in. Returns : An integer array with the number of non-overlapping occurrences of sub-string. Code #1: Python3 1== # Python Program illustrating # numpy.char.count() method import numpy as np # 2D array arr = ['vdsdsttetteteAAAa', 'AAAAAAAaattttds', 'AAaaxxxxtt', 'AAaaXDSDdscz'] print ("arr : ", arr) print ("Count of 'tt'", np.char.count(arr, 'tt')) print ("Count of 'tt'", np.char.count(arr, 'tt', start = 0)) print ("Count of 'tt'", np.char.count(arr, 'tt', start = 8)) Output: arr : ['vdsdsttetteteAAAa', 'AAAAAAAaattttds', 'AAaaxxxxtt', 'AAaaXDSDdscz'] Count of 'tt' [2 2 1 0] Count of 'tt' [2 2 1 0] Count of 'tt' [1 2 1 0] Code #2: Python3 1== # Python Program illustrating # numpy.char.count() method import numpy as np # 2D array arr = ['vdsdsttetteteAAAa', 'AAAAAAAaattttds', 'AAaaxxxxtt', 'AAaaXDSDdscz'] print ("arr : ", arr) print ("Count of 'Aa'", np.char.count(arr, 'Aa')) print ("Count of 'Aa'", np.char.count(arr, 'Aa', start = 8)) Output: arr : ['vdsdsttetteteAAAa', 'AAAAAAAaattttds', 'AAaaxxxxtt', 'AAaaXDSDdscz'] Count of 'Aa' [1 1 1 1] Count of 'Aa' [1 0 0 0] Comment More infoAdvertise with us Next Article numpy.count() in Python M mohit gupta_omg :) Follow Improve Article Tags : Python Python-numpy Python numpy-String Operation Practice Tags : python Similar Reads Numpy size() function | Python numpy.size() function in Python is used to count the number of elements in a NumPy array. You can use it to get the total count of all elements, or to count elements along a specific axis, such as rows or columns in a multidimensional array. This makes it useful when quickly trying to understand the 2 min read Numpy count_nonzero method | Python numpy.count_nonzero() function counts the number of non-zero values in the array arr. Syntax : numpy.count_nonzero(arr, axis=None) Parameters : arr : [array_like] The array for which to count non-zeros. axis : [int or tuple, optional] Axis or tuple of axes along which to count non-zeros. Default is 1 min read numpy.fromstring() function â Python numpy.fromstring() function create a new one-dimensional array initialized from text data in a string. Syntax : numpy.fromstring(string, dtype = float, count = -1, sep = ' ') Parameters : string : [str] A string that contained the data. dtype : [data-type, optional] Data-type of the array. Default d 1 min read Python List count() method The count() method is used to find the number of times a specific element occurs in a list. It is very useful in scenarios where we need to perform frequency analysis on the data.Let's look at a basic example of the count() method.Pythona = [1, 2, 3, 1, 2, 1, 4] c = a.count(1) print(c)Output3 Explan 2 min read Python len() Function The len() function in Python is used to get the number of items in an object. It is most commonly used with strings, lists, tuples, dictionaries and other iterable or container types. It returns an integer value representing the length or the number of elements. Example:Pythons = "GeeksforGeeks" # G 2 min read Like