numpy数组中的np.nan是否占用内存? [英] Does the np.nan in numpy array occupy memory?
问题描述
我有一个庞大的csv文件,无法将其加载到内存中.将其转换为libsvm格式可以节省一些内存. CSV文件中有很多Nan.如果我读取行并将它们存储为np.array,而np.nan为NULL,该数组是否仍会占用过多内存? 数组中的np.nan是否还会占用内存吗?
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 ?
推荐答案
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, NaN
s occupy the same amount of memory as any other number in the array.
这篇关于numpy数组中的np.nan是否占用内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!