さまざまなローリング タイプの単純な時系列を作成しようとしています。具体的な例の 1 つは、Panda python パッケージを使用した N 期間のローリング平均です。
次のエラーが表示されます: ValueError: DataFrame コンストラクターが正しく呼び出されません!
以下は私のコードです:
def py_TA_MA(v, n, AscendType):
df = pd.DataFrame(v, columns=['Close'])
df = df.sort_index(ascending=AscendType) # ascending/descending flag
M = pd.Series(df['Close'].rolling(n), name = 'MovingAverage_' + str(n))
df = df.join(M)
df = df.sort_index(ascending=True) #need to double-check this
return df
誰でもアドバイスできますか?
敬具