Skip to content

Instantly share code, notes, and snippets.

@bh1995
Created January 12, 2021 19:46
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/ad57d090800ed3f3f961970b389b6665 to your computer and use it in GitHub Desktop.
Save bh1995/ad57d090800ed3f3f961970b389b6665 to your computer and use it in GitHub Desktop.
# Plot nr neighbourhoods for top 30 cities
neighbourhood_list = listing_total.sort("total_neighbourhood", ascending=False)
neighbourhood_list_pd = neighbourhood_list.toPandas() # convert to pandas dataframe
list_neighbourhood_30 = neighbourhood_list_pd.iloc[1:31];
num = len(list_neighbourhood_30)*4
c = [i for i in range(0,num,4)]
plt.figure(figsize=(10,4))
plt.bar(c, list_neighbourhood_30['total_neighbourhood'],width=3, align='center', alpha=0.5)
plt.xticks(c,list_neighbourhood_30['city'],rotation=90)
plt.ylabel('total neighbourhood')
plt.xlabel('city')
plt.title('The total neighbourhood in top 30 cities')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment