0% found this document useful (0 votes)
32 views10 pages

Numpy and Pandas

The document provides an overview of various attributes and methods related to NumPy arrays, including dimensions, shape, size, data type, and item size. It also discusses methods for creating arrays, reshaping, and manipulating them, such as flattening and splitting. Additionally, it touches on DataFrame operations, particularly the dropna() method and its behavior with the inplace argument.

Uploaded by

thanhtuyen2066
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views10 pages

Numpy and Pandas

The document provides an overview of various attributes and methods related to NumPy arrays, including dimensions, shape, size, data type, and item size. It also discusses methods for creating arrays, reshaping, and manipulating them, such as flattening and splitting. Additionally, it touches on DataFrame operations, particularly the dropna() method and its behavior with the inplace argument.

Uploaded by

thanhtuyen2066
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

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:

You might also like