You can directly use the bins
parameter in the histogram function of a Series, like
import pandas as pd
url = 'https://drive.google.com/file/d/1lYZqeYH_AtUAUG5947Bd51JXJBrOP5Lp/view?usp=sharing'
path = 'https://drive.google.com/uc?export=download&id='+url.split('/')[-2]
df = pd.read_csv(path)
df['Active'].hist(bins=8)
or with the labels from the qcut
you can use it like this
levels = [f'Level_{i}' for i in range(8)]
df['Active_bins'] = pd.qcut(df['Active'], q=8, precision=0, labels=levels)
df.head()
# from https://stackoverflow.com/a/58288640/7752347
import matplotlib.pyplot as plt
fig,ax = plt.subplots()
hatches = ('\', '//', '..', '**', "!", '$', '^','#') # fill pattern
for (i, d),hatch in zip(df.groupby('Active_bins'), hatches):
d['Active'].hist(alpha=0.7, ax=ax, label=i, hatch=hatch)
ax.legend()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…