我有两个具有相同行数的 pyspark 数据框,但它们没有任何公共列。所以我使用 monotonically_increasing_id() 向它们添加新列
from pyspark.sql.functions import monotonically_increasing_id as mi
id=mi()
df1 = df1.withColumn("match_id", id)
cont_data = cont_data.withColumn("match_id", id)
cont_data = cont_data.join(df1,df1.match_id==cont_data.match_id, 'inner').drop(df1.match_id)
Run Code Online (Sandbox Code Playgroud)
但连接后生成的数据帧的行数较少。我在这里缺少什么。谢谢