ndarray.
ndim
the number of axes (dimensions) of the array.
ndarray.shape
the dimensions of the array. This is a tuple of integers indicating the size of the array in each dimension.
For a matrix with n rows and m columns, shape will be (n,m). The length of the shape tuple is therefore
the number of axes, ndim.
ndarray.size
the total number of elements of the array. This is equal to the product of the elements of shape.
ndarray.dtype
an object describing the type of the elements in the array. One can create or specify dtype’s using
standard Python types. Additionally NumPy provides types of its own. numpy.int32, numpy.int16, and
numpy.float64 are some examples.
ndarray.itemsize
the size in bytes of each element of the array. For example, an array of elements of type float64 has
itemsize 8 (=64/8), while one of type complex32 has itemsize 4 (=32/8). It is equivalent to
ndarray.dtype.itemsize.
ndarray.data
the buffer containing the actual elements of the array. Normally, we won’t need to use this attribute
because we will access the elements in an array using indexing facilities.
Np.zeros
Np.ones
Np.empty
Np.linspace
Np.arange(15).reshape(3,5) tự tạo một array từ 0-14
A2 = a1[ np.newaxis, :] // a1 có 5 shape (1,5)
A2= a1[ :, np.newaxis] // shape (5,1)
Np.hsplit(x, 3) a cắt x thành 3 thằng
Axis = 0 cột
Axis = 1 hàng
Np.flatten : You can use flatten to flatten your array into a 1D array: not change parent array
But when you use ravel, the changes you make to the new array will affect the parent array
Dataframe
Loc
index: chèn tên cho hàng
Note: By default, the dropna() method returns a new DataFrame, and will not change the original.
If you want to change the original DataFrame, use the inplace = True argument: