May 2019
Beginner
528 pages
29h 51m
English
array AttributesAn array object provides attributes that enable you to discover information about its structure and contents. In this section we’ll use the following arrays:
In [1]: import numpy as npIn [2]: integers = np.array([[1, 2, 3], [4, 5, 6]])In [3]: integersOut[3]:array([[1, 2, 3],[4, 5, 6]])In [4]: floats = np.array([0.0, 0.1, 0.2, 0.3, 0.4])In [5]: floatsOut[5]: array([ 0. , 0.1, 0.2, 0.3, 0.4])
NumPy does not display trailing 0s to the right of the decimal point in floating-point values.
array’s Element TypeThe array function determines an array’s element type from its argument’s elements. You can check the element type with an array’s dtype attribute:
In [6]: integers.dtypeOut[6]: dtype('int64') ...
Read now
Unlock full access