Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.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
List 如何基于行号列表拆分pyspark数据帧的行?_List_Sorting_Pyspark_Apache Spark Sql - Fatal编程技术网

List 如何基于行号列表拆分pyspark数据帧的行?

List 如何基于行号列表拆分pyspark数据帧的行?,list,sorting,pyspark,apache-spark-sql,List,Sorting,Pyspark,Apache Spark Sql,我创建了一个pyspark数据框,它的形象如下:- >>df f1 | f2 |……|fn |行数 ------------------------------ 10 | 50 | ... |100 | 1 20 | 50 | ... |200 | 2 30 | 50 | ... |300 | 3 40 | 50 | ... |400 | 4 50 | 50 | ... |500 | 5 然后,我还创建了随机的行号列表,如下所示:- my_list=[[2,5]、

我创建了一个pyspark数据框,它的形象如下:-

>>df
f1 | f2 |……|fn |行数
------------------------------
10 | 50 | ... |100 |    1
20 | 50 | ... |200 |    2
30 | 50 | ... |300 |    3
40 | 50 | ... |400 |    4
50 | 50 | ... |500 |    5
然后,我还创建了随机的行号列表,如下所示:-

my_list=[[2,5]、[4,1,3]]
根据此列表的结构,我希望创建pyspark数据帧,如下所示:-

>>split_df[0]
f1 | f2 |……|fn |行数
------------------------------
20 | 50 | ... |200 |    2
50 | 50 | ... |500 |    5
>>>拆分_df[1]
f1 | f2 |……|fn |行数
------------------------------
40 | 50 | ... |400 |    4
10 | 50 | ... |100 |    1
30 | 50 | ... |300 |    3
如何根据行号的
my_列表
拆分我的
df


我不希望使用
df.RandomSplit()
方法。

似乎您希望根据
my\u list
的值将数据帧拆分为一个列表

您可以在列表中使用
pyspark.sql.Column.isin

从pyspark.sql.functions导入col
split_df=[df.where(col('row_num').isin(x))表示我的_列表中的x]

您似乎希望根据
my\u list
的值将数据帧拆分为一个列表

您可以在列表中使用
pyspark.sql.Column.isin

从pyspark.sql.functions导入col
split_df=[df.where(col('row_num').isin(x))表示我的_列表中的x]