Created
June 17, 2020 00:36
-
-
Save dzakyputra/819e90d04f86f770ea3c7f79f00b3282 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
# Find the spending distribution | |
spending_distribution = transcript[transcript['event'] == 'transaction'].merge(profile, left_on='person', right_on='id') | |
# Histogram for the Male | |
plt.hist(spending_distribution[spending_distribution['gender'] == 'M']['amount'], | |
range=(0, 40), | |
alpha=0.5, | |
bins=40, | |
label='Male') | |
# Histogram for the Female | |
plt.hist(spending_distribution[spending_distribution['gender'] == 'F']['amount'], | |
range=(0, 40), | |
alpha=0.5, | |
bins=40, | |
label='Female') | |
plt.legend(loc='upper right') | |
plt.title('Spending per Transaction Distribution') | |
plt.xlabel('Amount ($)') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment