回答編集履歴
1
追記
test
CHANGED
@@ -1,3 +1,35 @@
|
|
1
1
|
groupbyを使うとできます。
|
2
2
|
|
3
3
|
https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.groupby.html
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
---
|
8
|
+
|
9
|
+
サンプルコード
|
10
|
+
|
11
|
+
```python
|
12
|
+
|
13
|
+
import pandas as pd
|
14
|
+
|
15
|
+
import numpy as np
|
16
|
+
|
17
|
+
import matplotlib.pyplot as plt
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
df = pd.DataFrame()
|
22
|
+
|
23
|
+
df['A'] = np.random.randint(2, size=(1000))
|
24
|
+
|
25
|
+
df['B'] = np.random.rand(1000)
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
ax = plt.subplot()
|
30
|
+
|
31
|
+
hist = df.groupby('A').hist(bins=np.linspace(0., 1., 10), ax=ax, alpha=0.5)
|
32
|
+
|
33
|
+
plt.show()
|
34
|
+
|
35
|
+
```
|