Matplotlib
Python
Olmo S. Zavala Romero
Numpy ndarray create Slicing 1D Slicing 2D Filtering Arange Random Meshgrid 2D image Where
Matplotlib
Olmo S. Zavala Romero
Center of Atmospheric Sciences, UNAM
September 7, 2016
NumPy basics
Python
Olmo S. Zavala Romero
Numpy ndarray create Slicing 1D Slicing 2D Filtering Arange Random Meshgrid 2D image Where
ndarray, a fast and space-efficient multidimensional array providing vectorized arithmetic operations and sophisticated broadcasting capabilities
Standard mathematical functions for fast operations on entire arrays of data without having to write loops
Tools for reading and writing array data to disk and working with memory-mapped files
Linear algebra, random number generation, and Fourier transform capabilities
McKinney, Wes. Python for Data Analysis. Beijing: OReilly, 2013.
ndarray basics
Python
Olmo S. Zavala Romero
Numpy ndarray create Slicing 1D Slicing 2D Filtering Arange Random Meshgrid 2D image Where
methods
Some useful methods: max, min, mean, nonzero, round, sort, sum, transpose We create arrays using the array method. We can perform +,* vectorized operations. Basic properties: 1 shape size of the matrix 2 dtype type of the matrix
import numpy as np
x = np.array([10,20,30]) y = np.array([1,2,3])
print('x.shape:',x.shape) print('x.dtype:',x.dtype) print('x+10:',x+10) print('x*10:',x*10) print('x+y:',x+y) print('x*y:',x*y)
ndarray basics
Python
Olmo S. Zavala Romero
Numpy ndarray create Slicing 1D Slicing 2D Filtering Arange Random Meshgrid 2D image Where
methods
Some useful methods: max, min, mean, nonzero, round, sort, sum, transpose We create arrays using the array method. We can perform +,* vectorized operations. Basic properties: 1 shape size of the matrix 2 dtype type of the matrix Exercise: function that receives two arrays and computes the dot product.
import numpy as np
x = np.array([10,20,30]) y = np.array([1,2,3])
print('x.shape:',x.shape) print('x.dtype:',x.dtype) print('x+10:',x+10) print('x*10:',x*10) print('x+y:',x+y) print('x*y:',x*y)
How to create ndarrays
Python
Olmo S. Zavala Romero
Numpy ndarray create Slicing 1D Slicing 2D Filtering Arange Random Meshgrid 2D image Where
We create arrays using the array[list] method. Or zero(d1) or zero((d1,d2,. . . )) method. Or ones(d1) or ones((d1,d2,. . . )) method. Or the arange(min,max) method, similar as range in python. Or the eye(rows,cols) method, creates identity matrices.
x = np.array([[10,20,30],[1,2,3]])
print(np.zeros(3),'\n') print(np.ones((2,3)),'\n') print(np.arange(1,3),'\n') print(np.eye(3,3),'\n')
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- matplotlib probability distribution
- matplotlib density plot
- pip install matplotlib windows
- how to install matplotlib python
- matplotlib hist color
- matplotlib hist bin
- matplotlib hist legend
- matplotlib hist bin width
- matplotlib histogram bins
- matplotlib draw lines
- matplotlib legend font colors
- matplotlib boxplot pandas