pysparkDataframe到rdd只取值

1hdlvixo  于 2021-05-29  发布在  Spark
关注(0)|答案(0)|浏览(217)

我想将dataframe转换为rdd,但只需采用如下rdd格式的值:
[(1, 19997, 16091), (1, 24374, 7017), (3, 20124, 21453)]
试过这个 final_df_new.rdd.map(lambda x:(x)) 但它给

[Row(total_properties_products_quantity=1, userIds=19997, productId=16091),
 Row(total_properties_products_quantity=1, userIds=24374, productId=7017),
 Row(total_properties_products_quantity=3, userIds=20124, productId=21453)]

我试过这个:

final_df_new.rdd.map(tuple).take(5)

给予:

[(1, 19997, 16091),
 (1, 24374, 7017),
 (3, 20124, 21453)]

有人知道怎么做吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题