Skip to content

Instantly share code, notes, and snippets.

@taylorplumer
Created October 5, 2019 03:54
Show Gist options
  • Save taylorplumer/989499353fa08a255eabc3014600931f to your computer and use it in GitHub Desktop.
Save taylorplumer/989499353fa08a255eabc3014600931f to your computer and use it in GitHub Desktop.
# Create a histogram of listings
neighbourhood_list = df['neighbourhood_cleansed'].unique().tolist()
hist_data = []
for neighbourhood in neighbourhood_list:
trace = go.Histogram(x = df.loc[df['neighbourhood_cleansed'] == neighbourhood].price.tolist(), opacity=0.75, name = neighbourhood)
hist_data.append(trace)
layout = go.Layout(barmode='stack', xaxis = dict(title='Listing Price'), yaxis = dict(title='Count'))
fig = go.Figure(data=hist_data, layout=layout)
# refer to README.md for dependencies on displaying Plotly Figure in jupyter notebook https://plot.ly/python/static-image-export/
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment