September 2018
Intermediate to advanced
472 pages
12h 2m
English
You may think that it is a waste of memory to use an int64 data type if the range of your values is so limited.
In fact, conscious of data-intensive situations, you can calculate how much memory space your Array_1 object is taking:
In: import numpy as np Array_1.nbytesOut: 24
In order to save memory, you can specify the type that best suits your array beforehand:
In: Array_1 = np.array(list_of_ints, dtype= 'int8')
Now, your simple array occupies just a fourth of the previous memory space. It may seem an obvious and overly simplistic example, but when dealing with millions of rows and columns, defining ...
Read now
Unlock full access