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 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 Python | Pandas Panel.count() In Pandas, Panel is a very important container for three-dimensional data. The names for the 3 axes are intended to give some semantic meaning to describing operations involving panel data and, in particular, econometric analysis of panel data. Panel.count() function is used to return number of obse 1 min read Count-files module in Python Count-files module is a command-line utility written in Python to get count and information of files with extensions. Its functionality to check files and extensions in any route provided can also be used to check files without or irrespective of extensions. Installation This module does not come bu 2 min read numpy.ma.MaskedArray.count() function - Python numpy.ma.MaskedArray.count() function count the non-masked elements of the array along the given axis. Syntax : numpy.ma.MaskedArray.count(self, axis=None, keepdims = no value) Parameters : axis : [None or int or tuple of ints, optional] Axis along which the count is performed. The default axis is N 2 min read Python - Itertools.count() Python Itertools are a great way of creating complex iterators which helps in getting faster execution time and writing memory-efficient code. Itertools provide us with functions for creating infinite sequences and itertools.count() is one such function and it does exactly what it sounds like, it co 3 min read Python | os.cpu_count() method ]os.cpu_count()Â method in Python is used to get the number of CPUs in the system. This method returns None if the number of CPUs in the system is undetermined. In this article, we will see how to get several cores in Python. Python os.cpu_count() Method SyntaxSyntax:Â os.cpu_count() Parameter:Â No par 1 min read Like