Spyder
- Provides an ipython environment from the IDE
Console -> Open ipython console
ipython
- Can use standard help function
help('numpy')
- Can get help on numpy array function
help('numpy.array')
- Import numpy with
import numpy as np
- Create numpy arrays with
array1 = np.array([3, 6, 9, 12])
- Find array data type with
array1.dtype
numpy arrays
- Create 2D array with
b = np.array([[3,6,9],[2,4,6]])
- Create zero array with
c = np.zeros((5,3))
- Create ones array with
d = np.ones((3,2))
- Find name of data type with
c.dtype.name
- Specify data type with
f = np.ones((3,4), dtype=np.int64)
- Create empty with
g = np.empty((3,3))
- Creat with range using
h = np.arange(0, 10, 2)
- Use
linspace
for floating point withi = np.linspace(0, 5, 13)
- Complex numbers with
cplx = np.array([[2,4],[3,6],[4,8]], dtype=complex)
- Can use
arange
withreshape
for building a matrix withm = np.arange(10).reshape(5,2)