Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.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 将Pandas代码重写为PySpark_Python_Pandas_Apache Spark_Pyspark_Spark Dataframe - Fatal编程技术网

Python 将Pandas代码重写为PySpark

Python 将Pandas代码重写为PySpark,python,pandas,apache-spark,pyspark,spark-dataframe,Python,Pandas,Apache Spark,Pyspark,Spark Dataframe,我的问候,我需要将Pandas的代码重写为PySpark。 我对PySpark没问题,但对熊猫没有任何技能。 你能告诉我下面的代码是做什么的吗 potent_cases.loc[potent_cases['status']==2,'is_too_old'] = potent_cases.loc[potent_cases['status']==2,:]\ .apply(lambda x: True if x['close_date'] < dt.now() - ti

我的问候,我需要将Pandas的代码重写为PySpark。 我对PySpark没问题,但对熊猫没有任何技能。 你能告诉我下面的代码是做什么的吗

potent_cases.loc[potent_cases['status']==2,'is_too_old'] = potent_cases.loc[potent_cases['status']==2,:]\
            .apply(lambda x: True if x['close_date']  < dt.now() - timedelta(2) else False,axis=1)

cases_to_create = potent_cases.loc[\
            ((potent_cases['status'] == 2) & ((potent_cases['is_too_old'] == True) |( potent_cases['manual'] == False)))|\
            (pd.isnull(potent_cases['status'])),['shop_id','plu','last_shelf_datetime']]
poverty_cases.loc[poverty_cases['status']=2,'is_too_old']=poverty_cases.loc[poverty_cases['status']=2,:]\
.apply(如果x['close_date']
您有一个名为
强效案例的df
。使用
loc
可以浏览所有行。当名为
status
的列的值为=2时,根据条件
x['close\u date']
,列
的同一行中的值将为
True
False


显然,第一行对于第二行的条件是必要的。在这里,如果条件满足,数据框
case\u to\u create
将使用
列的子集
“shop\u id',“plu',“last\u shelf\u datetime”

我想您忘记了包括(看起来像是一个基本的
过滤器
选择
,您可能会将其中的一半复制到PySpark中并运行)还有一个。你介意纠正一下吗?:)@user8371915不太好,我找不到这是什么意思
.loc[poverty_cases['status']==2,:]
。我不能运行Pandas代码(我希望可以)。当然,我完全同意lambda@AntonBondar-真的吗?您在
loc
上找不到任何文档?