Hi Guys,
Thanks for all your emails. In this note, we will be looking at Array Processing in Python.
This is part of lectures on Learning Python for Data Analysis and Visualization by Jose Portilla on Udemy.
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
points = np.arange(-5,5,0.01)
dx, dy = np.meshgrid(points,points)
dx
dy
z = (np.sin(dx) + np.sin(dy))
z
plt.imshow(z)
plt.imshow(z)
plt.colorbar()
plt.title('Plot of sin(x) + sin(y)')
#numpy where
A = np.array([1,2,3,4])
B = np.array([100,200,300,400])
condition = np.array([True, True, False, False])
answer = [(A_val if cond else B_val) for A_val, B_val, cond in zip(A, B, condition)]
answer
answer2 = np.where(condition,A,B)
answer2
from numpy.random import randn
arr = randn(5,5)
arr
np.where(arr<0,0,arr)
arr2 = np.array([[1,2,3],[4,5,6],[7,8,9]])
arr2
arr2.sum()
arr2.sum(0)
arr2.sum(1)