Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

numpy count the number of 1s in array

a = numpy.array([0, 3, 0, 1, 0, 1, 2, 1, 0, 0, 0, 0, 1, 3, 4])
unique, counts = numpy.unique(a, return_counts=True)
dict(zip(unique, counts))
{0: 7, 1: 4, 2: 1, 3: 2, 4: 1}
Comment

number of elements in the array numpy

import numpy as np
arr = np.array([1,2,3])
arr.size
Comment

PREVIOUS NEXT
Code Example
Python :: copy file in python3 
Python :: apple 
Python :: graphics in python in repl 
Python :: cv_bridge.core.CvBridgeError: [8UC4] is not a color format. but [bgr8] is. The conversion does not make sense 
Python :: divide by zero errors when using annotate 
Python :: x= [10] def List_ex(): x.append(20) def add_list(): x=[30,40] x.append(50) print (x) List_ex() print (x) add_list() print (x) 
Python :: apolatrix 
Python :: python: separate lines including the period or excalamtion mark and print it to the prompt.. 
Python :: pandas remove prefix from columns 
Python :: how to get words from a string in python 
Python :: how to change python version on linux 
Python :: # load multiple csv files into dataframe 
Python :: how to save inputs python 
Python :: django logout 
Python :: create numpy table with random values in range 
Python :: how to put more than one file type in pysimplegui 
Python :: youtube to mp3 python 
Python :: python format float as currency 
Python :: How to use PatBlt in Python 
Python :: date format in django template 
Python :: write csv python pandas stack overflow 
Python :: who is elcharitas 
Python :: firebase-admin python 
Python :: sklearn fit pandas dataframe 
Python :: serializers.py include all fields 
Python :: variance calculation python manually 
Python :: python search for string in file 
Python :: python custom array sort 
Python :: plt.imshow not showing 
Python :: make text bold python 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =