-
-
Save amankharwal/5ac0d242f3379ae07f7a72887fe76507 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
p = df.groupby('Rating')['Rating'].agg(['count']) | |
# get movie count | |
movie_count = df.isnull().sum()[1] | |
# get customer count | |
cust_count = df['Cust_Id'].nunique() - movie_count | |
# get rating count | |
rating_count = df['Cust_Id'].count() - movie_count | |
ax = p.plot(kind = 'barh', legend = False, figsize = (15,10)) | |
plt.title('Total pool: {:,} Movies, {:,} customers, {:,} ratings given'.format(movie_count, cust_count, rating_count), fontsize=20) | |
plt.axis('off') | |
for i in range(1,6): | |
ax.text(p.iloc[i-1][0]/4, i-1, 'Rating {}: {:.0f}%'.format(i, p.iloc[i-1][0]*100 / p.sum()[0]), color = 'white', weight = 'bold') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment