Skip to content

Instantly share code, notes, and snippets.

@1ambda
Created December 27, 2021 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1ambda/e516cb5ee85be4ddab1b33e7fbb9c7db to your computer and use it in GitHub Desktop.
Save 1ambda/e516cb5ee85be4ddab1b33e7fbb9c7db to your computer and use it in GitHub Desktop.
dateStart = "2019-12-01"
dateEnd = "2019-12-31"
dfCalendarSalesFiltered = dfListingCalendar\
.where(col("available") == lit('f'))\
.withColumn("date", col("date").cast(DateType()))\
.where(col("date").between(lit(dateStart).cast(DateType()), lit(dateEnd).cast(DateType())))
dfCalendarSalesDec = dfCalendarSalesFiltered\
.groupBy("date")\
.agg(countDistinct("listing_id"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment