Created
December 27, 2021 12:32
-
-
Save 1ambda/ff840accd6a947f18c90d991537ec339 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dfListingReviewStat = dfListingReview\ | |
.groupBy(col("listing_id"))\ | |
.agg(count("*").alias("count_review")) | |
dfListingReview = dfListingMeta\ | |
.select( | |
col("id").alias("listing_id"), | |
col("name").alias("listing_name"))\ | |
.alias("LISTING_META")\ | |
.join( | |
other = dfListingReviewStat.alias("LISTING_REVIEW"), | |
on = col("LISTING_META.listing_id") == col("LISTING_REVIEW.listing_id"), | |
how = "inner" | |
)\ | |
.select( | |
col("LISTING_META.listing_id"), | |
col("LISTING_META.listing_name"), | |
coalesce(col("LISTING_REVIEW.count_review"), lit(0)).alias("count_review") | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment