Home > OS >  Merging in PySpark (both left and right)
Merging in PySpark (both left and right)

Time:11-22

What is the equivalent code in PySpark to merge two different dataframe (both left and right)?

df_merge = pd.merge(t_df, d_df, left_on='a_id', right_on='d_id', how='inner')

CodePudding user response:

join is the equivalent of merge in pandas.

The equivalent PySpark logic for the merge code you had shared would be


t_df.join(d_df, t_df["a_id"] == d_df["d_id"], "inner")

  • Related