teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

追記

2017/11/20 14:50

投稿

mkgrei
mkgrei

スコア8562

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
+ ```