ValueError:操作数不能与使用statsmodel分解的形状一起与形状一起广播

时间:2019-10-17 03:37:09

标签: python time-series statsmodels

我有以下代码,可使用statsmodel分解时间序列数据,但会出错:

import pandas as pd
import numpy as np
from pandas import datetime
from statsmodels.tsa.seasonal import seasonal_decompose

# load data
def parser (x):
    return datetime.strptime(x,'%d/%m/%Y')
orders = pd.read_csv('time_series_total.csv',index_col=0,parse_dates= [0],date_parser=parser,header=0)
#Decompose time-series
# Multiplicative Decomposition 
result_mul = seasonal_decompose(orders['orders'], 
model='multiplicative',extrapolate_trend='freq')

# Additive Decomposition
result_add = seasonal_decompose(orders['orders'], 
model='additive',extrapolate_trend='freq')

它显示此错误:

ValueError: operands could not be broadcast together with shapes (32,) (74,) 

这是我加载和打印时的时间序列数据(前5个):

            orders
weeks             
2019-03-11      43
2019-03-18      14
2019-03-25       2
2019-04-01     229
2019-04-08      46

0 个答案:

没有答案