Skip to content

Instantly share code, notes, and snippets.

@karamanbk
Created May 3, 2019 20:04
Show Gist options
  • Save karamanbk/01623d1449e9aff02c0ea5d10e52a112 to your computer and use it in GitHub Desktop.
Save karamanbk/01623d1449e9aff02c0ea5d10e52a112 to your computer and use it in GitHub Desktop.
#get order counts for each user and create a dataframe with it
tx_frequency = tx_uk.groupby('CustomerID').InvoiceDate.count().reset_index()
tx_frequency.columns = ['CustomerID','Frequency']
#add this data to our main dataframe
tx_user = pd.merge(tx_user, tx_frequency, on='CustomerID')
#plot the histogram
plot_data = [
go.Histogram(
x=tx_user.query('Frequency < 1000')['Frequency']
)
]
plot_layout = go.Layout(
title='Frequency'
)
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