numpy数组中的np.nan是否占用内存?

编程入门 行业动态 更新时间:2024-10-27 03:33:01
本文介绍了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 ?

推荐答案

使用NaN和inf)也由特定的二进制模式表示,该模式占用与任何数字浮点值相同的位数.因此,NaN占用的内存量与数组中的任何其他数字相同.

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是否占用内存?

本文发布于:2023-07-30 16:19:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1250987.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组中   内存   numpy   nan   np

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!