Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

count values in numpy list python

>>> import numpy
>>> y = np.array([1, 2, 2, 2, 2, 0, 2, 3, 3, 3, 2, 2])

>>> numpy.count_nonzero(y == 1)
1
>>> numpy.count_nonzero(y == 2)
7
>>> numpy.count_nonzero(y == 3)
3
Comment

PREVIOUS NEXT
Code Example
Python :: sample data frame in python 
Python :: python cut string after character 
Python :: addition in python 
Python :: how to convert gb to mb in python 
Python :: numpy empty image 
Python :: how to import date python 
Python :: merge dictionaries in python 
Python :: Count NaN values of an DataFrame 
Python :: pandas most frequent value 
Python :: python unicode is not defined 
Python :: pywhatkit 
Python :: save a torch tensor 
Python :: loop append to list python 
Python :: pd df to series 
Python :: clahe opencv 
Python :: pil image resize not working 
Python :: change variable type python 
Python :: python scanner class 
Python :: django admin customization 
Python :: remove index from dataframe pandas 
Python :: pyttsx3 set volume 
Python :: plotly hide color bar 
Python :: pandas inplace 
Python :: how to find the location of a character in a string in python 
Python :: python compute SSIM 
Python :: how to read excel file in python 
Python :: Python Removing Directory or File 
Python :: python scatter plot legend 
Python :: python keyboardinterrupt 
Python :: pandas change dtype to timestamp 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =