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 any in string 
Python :: exception handling in tkinter 
Python :: task.loop discord.py 
Python :: pandas convert string to float 
Python :: is python easy or hard to learn 
Python :: python reply to email 
Python :: how to add hyperlink in jupyter notebook 
Python :: how to make a 2d array in python 
Python :: python secret 
Python :: calendar library in python 
Python :: merge pdf 
Python :: reverse range python 
Python :: use latest file on aws s3 bucket python 
Python :: for in print pyhton 
Python :: queue peek python 
Python :: reversing in python 
Python :: dictionary increment 
Python :: odoo model 
Python :: Syntax of Opening a File in python 
Python :: django venv activate 
Python :: dockerize django 
Python :: python output text 
Python :: python run linux command and get output 
Python :: extract specific key values from python dictionary 
Python :: hmac sha256 python 
Python :: python function create null matrix 
Python :: smooth interpolation python 
Python :: remove key from dictionary python 
Python :: Smart Weather Information App Using Python 
Python :: Tree Traversals inorder,preorder and postorder 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =