Skip to content

Instantly share code, notes, and snippets.

@drazenz
Created April 14, 2019 19:31
Show Gist options
  • Select an option

  • Save drazenz/d3b710d6644f16230d07f2771935236d to your computer and use it in GitHub Desktop.

Select an option

Save drazenz/d3b710d6644f16230d07f2771935236d to your computer and use it in GitHub Desktop.
bin_labels = ['Low (0-100)', 'Medium (100-150)', 'High (150+)']
data['horsepower-group'] = pd.cut(
data['horsepower'],
bins=[0, 100, 150, data['horsepower'].max()],
labels=bin_labels
)
data['cnt'] = np.ones(len(data))
g = data.groupby(['horsepower-group', 'make']).count()[['cnt']].reset_index().replace(np.nan, 0)
plt.figure(figsize=(3, 11))
heatmap(
x=g['horsepower-group'],
y=g['make'],
size=g['cnt'],
marker='h',
x_order=bin_labels
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment