Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the np.nan in numpy array occupy memory?

I have a huge file of csv which can not be loaded into memory. Transforming it to libsvm format may save some memory. There are many nan in csv file. If I read lines and store them as np.array, with np.nan as NULL, will the array still occupy too much memory ? Does the np.nan in array also occupy memory ?

like image 678
yanachen Avatar asked Jan 03 '23 20:01

yanachen


1 Answers

When working with floating point representations of numbers, non-numeric values (NaN and inf) are also represented by a specific binary pattern occupying the same number of bits as any numeric floating point value. Therefore, NaNs occupy the same amount of memory as any other number in the array.

like image 156
Shai Avatar answered Jan 13 '23 13:01

Shai