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