Skip to content

Instantly share code, notes, and snippets.

@bh1995
Created January 12, 2021 21:22
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 bh1995/96366643ce6546891b6da9dc4e832ed0 to your computer and use it in GitHub Desktop.
Save bh1995/96366643ce6546891b6da9dc4e832ed0 to your computer and use it in GitHub Desktop.
beijing_popularity_month = beijing_popularity.groupBy(f.month(beijing_popularity["date"]).alias("month")).count().sort("month", ascending=True)
beijing_popularity_month_pd = beijing_popularity_month.toPandas()
num = len(beijing_popularity_month_pd)*4
c = [i for i in range(0,num,4)]
plt.figure(figsize=(10,4))
plt.bar(c, beijing_popularity_month_pd['count'],width=3, align='center', alpha=0.5)
plt.xticks(c,beijing_popularity_month_pd["month"])
plt.ylabel('Popularity')
plt.xlabel('Month')
plt.title('The Popularity of Beijing by month')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment