Skip to content

Instantly share code, notes, and snippets.

@dzakyputra
Created June 17, 2020 00:36
Show Gist options
  • Save dzakyputra/819e90d04f86f770ea3c7f79f00b3282 to your computer and use it in GitHub Desktop.
Save dzakyputra/819e90d04f86f770ea3c7f79f00b3282 to your computer and use it in GitHub Desktop.
# 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