numpy数组中的np.nan是否占用内存? [英] Does the np.nan in numpy array occupy memory?

查看:239
本文介绍了numpy数组中的np.nan是否占用内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个庞大的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, NaNs occupy the same amount of memory as any other number in the array.

这篇关于numpy数组中的np.nan是否占用内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆