vector 123 * scalor 3 = 123123123, 369, error
these are reasonable answers
More vectorized operation
math operation
add, subtract, multiply, divide, expertise
Logical opereation
&, |, ~
Comparison operations
>, >=, <, <=, ==, !=
import numpy as np if False: a = np.array([1, 2, 3, 4]) b = np.array([1, 2, 1, 2]) print a + b print a – b print a * b print a / b print a ** b if False a = np.array([1, 2, 3, 4]) b = 2 print a + b print a – b print a * b print a / b print a ** b if False: a = np.array([1,2,3,4,5]) b = np.array([5,4,3,2,1]) print a > b print a >= b print a < b print a <= b print a == b print a != b
code snippet
import numpy as np
a = np.array([1,2,3,4])
b = a
a += np.array([1,1,1,1])
print b
+= operates in-place while + does not
import pandas as pandas if False: s1 = pd.Series([1,2,3,4], index=['a','b','c','d']) s2 = pd.Series([10,20,30,40], index['a','b','c','d']) print s1 + s2 if False: s1 = pd.Series([1,2,3,4], index=['a','b','c','d']) s2 = pd.Series([10,20,30,40], index['a','b','c','d']) print s1 + s2 if False: s1 = pd.Series([1,2,3,4], index=['a','b','c','d']) s2 = pd.Series([10,20,30,40], index['a','b','c','d']) print s1 + s2 if False: s1 = pd.Series([1,2,3,4], index=['a','b','c','d']) s2 = pd.Series([10,20,30,40], index['a','b','c','d']) print s1 + s2