Last active
May 3, 2019 14:46
-
-
Save karamanbk/2f981cf1f31c237b4291003d507bd89f 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
#creating a new dataframe with UK customers only | |
tx_uk = tx_data.query("Country=='United Kingdom'").reset_index(drop=True) | |
#creating monthly active customers dataframe by counting unique Customer IDs | |
tx_monthly_active = tx_uk.groupby('InvoiceYearMonth')['CustomerID'].nunique().reset_index() | |
#print the dataframe | |
tx_monthly_active | |
#plotting the output | |
plot_data = [ | |
go.Bar( | |
x=tx_monthly_active['InvoiceYearMonth'], | |
y=tx_monthly_active['CustomerID'], | |
) | |
] | |
plot_layout = go.Layout( | |
xaxis={"type": "category"}, | |
title='Monthly Active Customers' | |
) | |
fig = go.Figure(data=plot_data, layout=plot_layout) | |
pyoff.iplot(fig) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment