Created
September 20, 2020 14:47
-
-
Save gbarreiro/a292750d84e208b408420dc7fefc61ac to your computer and use it in GitHub Desktop.
Best cuisines: insight 1
This file contains hidden or 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
fig = plt.figure() | |
for index, city in enumerate(cities): | |
# For each city, get the top 10 cuisines and plot them in a horizontal bar graph | |
ax = fig.add_subplot(3, 3, index+1) | |
# Get the top 10 cuisines for the city | |
cuisines = cuisines_city_normalized.loc[city] | |
cuisines = cuisines.sort_values(ascending=False).head(10).sort_values(ascending=True) | |
# Plot in red the bar with the local cuisine, plot in blue the rest | |
local_cuisine = city_local_cuisines[city] | |
color = '' | |
for i in cuisines.keys(): | |
if i == local_cuisine: | |
color = color + 'r' | |
else: | |
color = color + 'b' | |
# Plot the top 10 cuisines | |
cuisines.plot(kind='barh', ax=ax, figsize=(16, 14), color=list(color)) | |
ax.set_title(city) | |
ax.set_xlabel("% of restaurants") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment