はじめて質問いたします。
IPython データサイエンスクックブック レシピ8.2 を試しています。
次の箇所でエラーが出てしまいます。
プログラム中の~も初体験です。~がエラーのもとなのかなぁと思います。
エラーへの対処方法と~を教えてください。よろしくお願いします。
#男性と女性の生存者を年齢の関数として表示
#We define a few boolean vectors. 論理配列をいくつか定義する
female = x[:,:-1] == 1
survived = y == 1
#This vector contains the age of the passengers この配列は乗客の年齢を格納する
age = x[:,1]
#We compute a few histograms. ヒストグラムを作成
bins_ = np.arange(0,81,5)
S = {'male': np.histogram(age[survived & ~female],
bins = bins_)[0],
'female': np.histogram(age[survived & female],
bins = bins_)[0]}
D = {'male': np.histogram(age[~survived & ~female],
bins = bins_)[0],
'female': np.histogram(age[~survived & female],
bins = bins_)[0]}
ValueError Traceback (most recent call last)
<ipython-input-9-e78d2e2e0fcf> in <module>()
7 #We compute a few histograms. ヒストグラムを作成
8 bins_ = np.arange(0,81,5)
----> 9 S = {'male': np.histogram(age[survived & female],
10 bins = bins_)[0],
11 'female': np.histogram(age[survived & female],
ValueError: operands could not be broadcast together with shapes (714,) (714,2)
回答2件
あなたの回答
tips
プレビュー