import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19])
[(0.982, 7.0], (0.982, 7.0], (0.982, 7.0], (0.982, 7.0], (0.982, 7.0], ..., (13.0, 19.0], (13.0, 19.0], (13.0, 19.0], (13.0, 19.0], (13.0, 19.0]]
Length: 19
Categories (3, interval[float64]): [(0.982, 7.0] < (7.0, 13.0] < (13.0, 19.0]]
pd.cut(l, bins=3, labels=["small", "medium", "large"])
['small', 'small', 'small', 'small', 'small', ..., 'large', 'large', 'large', 'large', 'large']
Length: 19
Categories (3, object): ['small' < 'medium' < 'large']
df = pd.DataFrame(pd.cut(l, bins=3, labels=["small", "medium", "large"]))
df
|
0 |
0 |
small |
1 |
small |
2 |
small |
3 |
small |
4 |
small |
5 |
small |
6 |
small |
7 |
medium |
8 |
medium |
9 |
medium |
10 |
medium |
11 |
medium |
12 |
medium |
13 |
large |
14 |
large |
15 |
large |
16 |
large |
17 |
large |
18 |
large |
df.value_counts().plot(kind='barh')
plt.show()