Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中将两列相乘时出现内存错误_Python_Pandas_Numpy_Jupyter - Fatal编程技术网

在python中将两列相乘时出现内存错误

在python中将两列相乘时出现内存错误,python,pandas,numpy,jupyter,Python,Pandas,Numpy,Jupyter,我有一个如下所示的数据集: |---------------------|------------------|------------------| | Rating | Installs | Price | |---------------------|------------------|------------------| | 2.1 | 10,000+ | $8

我有一个如下所示的数据集:

|---------------------|------------------|------------------|
|        Rating       |     Installs     |     Price        |
|---------------------|------------------|------------------|
|          2.1        |      10,000+     |      $8.75       |
|---------------------|------------------|------------------|
|          4.2        |       2,000+     |      $5.99       |
|---------------------|------------------|------------------|
|          3.0        |     50,0000+     |      $3.22       |
|---------------------|------------------|------------------|
我想计算所有具有 评级为3.1或以下。 我正在使用以下代码(python jupyter)处理Price字符串并安装以获取整数值:


但是我用这个命令得到内存错误。如何使此代码更高效,从而在不给出任何内存错误的情况下计算总利润。

变量和函数名称应遵循带下划线的
小写形式。您应该将代码拆分一点,首先将值转换为浮点数
data.loc[data['Rating']>=3.1][“Installs”]
这违背了使用
loc
的意义。请分享一个。@ACM这解决了我的问题。谢谢,你做了什么?你应该考虑用重构代码发布答案。
Installs = data.loc[ data['Rating']>=3.1 ]["Installs"]
Price = data.loc[ data['Rating']>=3.1 ]["Price"]
Profit = Installs.apply( lambda row: int( sub(r'[^\d.]', '',row )) ) * Price.apply( lambda row: row.strip('$') )