Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

numpy addition operation using numpy functions

import numpy as np
  
# Defining both the matrices
a = np.array([5, 72, 13, 100])
b = np.array([2, 5, 10, 30])
  
# Performing addition using arithmetic operator
add_ans = a+b
print(add_ans)
  
# Performing addition using numpy function
add_ans = np.add(a, b)
print(add_ans)
  
# The same functions and operations can be used for
# multiple matrices
c = np.array([1, 2, 3, 4])
add_ans = a+b+c
print(add_ans)
  
add_ans = np.add(a, b, c)
print(add_ans)
Comment

addition array numpy

data = np.array([1, 2])
ones = np.ones(2, dtype=int)
data + ones
Comment

PREVIOUS NEXT
Code Example
Python :: python read and write lines in file 
Python :: python zahl abrunden 
Python :: plotly two y axis bar chart 
Python :: Python - pasword hashed 
Python :: Get hours, minutes, seconds, and microseconds using time class 
Python :: scraped text in Russian encoding python 
Python :: Top n rows of each group 
Python :: copy bdc to feature class arcpy 
Python :: sample mapping in pandas 
Python :: accessing a specific slide using python 
Python :: python synta error 
Python :: numpy topk 
Python :: python get stringvar value 
Python :: how to select the three highest entries within a category in pandas 
Python :: python4 
Python :: sample k-means clustering 
Python :: bold colors in pytohn 
Python :: how to prefix numbers with zero in python 
Python :: reemplazar un caracter de un string 
Python :: looping through models and plotting their performance 
Python :: Mapping using dictionary 
Python :: Delete files in folder by extension 
Python :: py variable space padding 
Python :: get_string python 
Python :: how to get a rectangular grid out of two given one-dimensional arrays 
Python :: finns = False 
Python :: how to create datetime from negative epoch in python 
Python :: how to dynamically search for a class variable in python 
Python :: def f(x) python 
Python :: mute button tkinter 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =