python-3.x - Pandas: I want to multiply two columns with 19 million rows, but system runs out of memory (Memory Error)
问题描述
I want to multiply two columns with 19 million rows and add it to a new column.
So for example, I have a column col_X
and a column col_Y
, with 19 millions records. And col_X has values of type 'float' and col_Y has values of type 'numpy.float64'. I want to multiply them and add the values to a new column New_col
.The code I am using for mulitplication is:
df['New_col']=df['col_X']*df['col_Y']
This worked well when I was working with 10 million records. But now with 19 million, I am facing the following error:
Memory Error: (lambda x: op(x, rvalues)) MemoryError)
I am thinking of multiplying these two columns in two parts (i.e. multiply initial 10 million records first and then multiply the next 9 million records after that, and then later join the two series and add it to a new column), but I don't know how to go about implementing this. Is there any other solution?
I am new to Python and would really appreciate your help.
解决方案
推荐阅读
- javascript - 如何设置和使用工具提示?
- python-3.x - 更新熊猫数据框列表中的列
- vue.js - Vue 2 / Vue CLI 3:创建异步单文件组件
- java - 使用最新版本的 jdbc 连接器连接到 1.8 HyperSQL 数据库
- python - 编程面试要素中的死锁问题 19.5
- typescript - 找不到 Firebase 功能的 Typescript 声明
- c - 在 C 中填充二维 int 数组的最简单方法
- java - 如何将多个对象链接到队列
- arrays - Ruby - 将文件行拆分为数组名称中的索引
- c# - 使用搜索文本框中的值过滤数据网格视图列表:“对象引用未设置为对象的实例。”