import numpy as np
Data Structure:
- Series
- DataFramework:
A 2-D labeled data structure with columns of potentially different types.
DataFramework
DF Information:
df.index
df.columns
ndarray
- n multi dimension array
- A generic multidimensional container for homogeneous data, so it should be same type.
- It will convert type into homogeneous type
Create
1.
data1 = [1,2,3,4]
arr = np.array(data1)
arr = np.array(data1, dtype=np.float64)
out: array([1,2,3,4])
- Use
zeros
orones
np.zeros(10)
np.ones(11) - Use
arange
np.arange(15)
- Use
eye
/identity
to create a Square N x N identity matrix
Operations
Vectorization
arr * arr
arr - arr
Useful functions
- dtype
data.dtype
- ndim
arr2.ndim
-
shape
- asarray
copy or in-place
- If you want a copy of a slice of an ndarray instead of view, you will need to explicitly copy the array. Use
arr[5:8].copy()
近期评论