計算の比較をしたかったのですがエラーが出てしまい解決策が分からす質問させていただきました
python
1path = "8254.csv" 2df = pd.read_csv(path) 3df.index = pd.to_datetime(df["Date"]) 4 5volume = df['Volume'].dropna() 6close = df['Adj Close'].dropna() 7date = df['Date'].dropna() 8 9def Bollinger(df,window=25): 10 11 bband = pd.DataFrame() 12 bband['close'] = df['Adj Close'] 13 bband['ma'] = df['Adj Close'].rolling(window=20).mean() 14 bband['sigma'] = df['Adj Close'].rolling(window=20).std() 15 bband['ma+2sigma'] = bband['ma'] + (bband['sigma'] * 2) 16 bband['ma-2sigma'] = bband['ma'] - (bband['sigma'] * 2) 17 bband['ma+3sigma'] = bband['ma'] + (bband['sigma'] * 3) 18 bband['ma-3sigma'] = bband['ma'] - (bband['sigma'] * 3) 19 bband["diffplus"] = bband.close - bband["ma+2sigma"] 20 bband["diffminus"] = bband["ma-2sigma"] - bband.close 21 s_up = bband[bband["diffplus"]>0]["close"] 22 s_down = bband[bband["diffminus"]>0]["close"] 23 24 if bband["ma-2sigma"] > df['Adj Close']: 25 print(bband["ma-2sigma"][-1:]) 26 27 if bband["ma-3sigma"][-1:] > df['Adj Close'][-1:]: 28 print(bband["ma-3sigma"][-1:]) 29Bollinger(df,window=25) 30
エラーの内容
error
1ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
python
1if bband["ma-2sigma"] > df['Adj Close']: 2#を 3if bband["ma-2sigma"] > bband['close']: 4#にしても同じエラーが出ました。
データの中身はこんな感じです。
data
1Date Open High Low Close Adj Close Volume 22015-01-21 750.000000 750.000000 750.000000 750.000000 750.000000 4700 32015-01-22 750.000000 760.000000 740.000000 750.000000 750.000000 11600 42015-01-23 750.000000 760.000000 750.000000 750.000000 750.000000 9900 52015-01-26 740.000000 760.000000 740.000000 750.000000 750.000000 10000 6... 72015-01-21 750.000000 750.000000 750.000000 750.000000 750.000000 4700 82015-01-22 750.000000 760.000000 740.000000 750.000000 750.000000 11600 92015-01-23 750.000000 760.000000 750.000000 750.000000 750.000000 9900 102015-01-26 740.000000 760.000000 740.000000 750.000000 750.000000 10000
他に必要な物があれば追記いたします。
わかる方いれば教えていください、よろしくお願いいたします。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。