import pyspark.sql.functions as f
join_keys = ["D_ACCOUNTS_ID", "D_APPS_ID", "D_CONTENT_PAGE_ID"]
df = (
df
.join(df_forecast, join_keys, 'left')
.select(
*join_keys,
# selecting columns from left side of the join that are not in the join keys.
*[df[element].alias('df_'+element) for element in df.columns if element not in join_keys],
# selecting columns from right side of the join that are not in the join keys.
*[df_forecast[element].alias('df_forecast_'+element) for element in df_forecast.columns if element not in join_keys]
)
)
1条答案
按热度按时间e4eetjau1#