只需过滤并选择:
result = users_df.where(users_df._id == chosen_user).select("gender")或搭配
col
from pyspark.sql.functions import colresult = users_df.where(col("_id") == chosen_user).select(col("gender"))最后,PySpark
Row只是
tuple带有一些扩展名的一个,因此您可以例如
flatMap:
result.rdd.flatMap(list).first()
或
map类似这样的东西:
result.rdd.map(lambda x: x.gender).first()



