Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

sum of a numpy array

>>> np.sum([0.5, 1.5])
2.0
>>> np.sum([0.5, 0.7, 0.2, 1.5], dtype=np.int32)
1
>>> np.sum([[0, 1], [0, 5]])
6
>>> np.sum([[0, 1], [0, 5]], axis=0)
array([0, 6])
>>> np.sum([[0, 1], [0, 5]], axis=1)
array([1, 5])
>>> np.sum([[0, 1], [np.nan, 5]], where=[False, True], axis=1)
array([1., 5.])
Comment

Python Sum of an array in NumPy

import numpy as np
a=np.array([[1,4],[3,5]])
b=np.sum(a,axis=1)
print(b)
Comment

PREVIOUS NEXT
Code Example
Python :: python-telegram-bot send file 
Python :: mechanize python 
Python :: django pagination 
Python :: python random array shuffle 
Python :: python uuid 
Python :: how to get a summary of a column in python 
Python :: create dict from two lists 
Python :: how to create python environment 
Python :: python read excel 
Python :: spotify api python 
Python :: how to put python code on a website 
Python :: fibonacci series using dynamic programmig approach 
Python :: python dictonary set default 
Python :: split at first occurrence python 
Python :: remove multiple strings from list python 
Python :: unique value python 
Python :: how to make a clock in python 3 
Python :: python __str__ vs __repr__ 
Python :: beautiful soap python get the link online 
Python :: Drop multiple columns by name 
Python :: doomsday fuel foobar 
Python :: import stock data from yahoo finance 
Python :: python string manipulation 
Python :: python string find 
Python :: python get env 
Python :: drop na pandas 
Python :: float to int in python 
Python :: python using re trimming white space 
Python :: days to int 
Python :: python funtion 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =