Skip to content

Instantly share code, notes, and snippets.

@8080labs
Last active February 6, 2020 16:52
Show Gist options
  • Save 8080labs/e3f1372f7b7cc8c8aa90bc4a6189084f to your computer and use it in GitHub Desktop.
Save 8080labs/e3f1372f7b7cc8c8aa90bc4a6189084f to your computer and use it in GitHub Desktop.
plotly_histogram
import plotly.graph_objs as go
def interactive_histogram(df, column_name):
series = df[column_name]
# Change size to anything you want in order to adjust the binwidth
trace = go.Histogram(x=series, xbins={"size": None})
figure_widget = go.FigureWidget(
data=[trace],
layout=go.Layout(
yaxis={"title": "Count"},
xaxis={"title": column_name},
bargap=0.05,
)
)
return figure_widget
interactive_histogram(df, "arr_delay")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment