Explorar o código

Merge branch 'bzq1/fix_stl_refresh_bug' of eta_server/eta_index_lib into debug

baoziqiang hai 3 meses
pai
achega
1d9a804b7c
Modificáronse 1 ficheiros con 6 adicións e 6 borrados
  1. 6 6
      services/edb_data_calculate_stl.go

+ 6 - 6
services/edb_data_calculate_stl.go

@@ -399,20 +399,20 @@ func ParseStlExcel(excelPath string) (TrendChart, SeasonalChart, ResidualChart C
 
 func execStlPythonCode(path, toPath string, period, seasonal, trend, trendDeg, seasonalDeg, lowPassDeg int, fraction float64, robust bool) (err error) {
 	pythonCode := `
+import json
+import warnings
+warnings.filterwarnings('ignore')
 import pandas as pd
 from statsmodels.tsa.seasonal import STL
 from statsmodels.nonparametric.smoothers_lowess import lowess
 from statsmodels.tsa.stattools import adfuller
 from statsmodels.stats.diagnostic import acorr_ljungbox
 import numpy as np
-import json
-import warnings
-warnings.filterwarnings('ignore')
 
 file_path = r"%s"
-df = pd.read_excel(file_path, parse_dates=['日期'])
+df = pd.read_excel(file_path, parse_dates=['日期'], engine='openpyxl')
 df.set_index('日期', inplace=True)
-
+df = df[df.index.notna()]
 
 period = %d
 seasonal = %d
@@ -439,7 +439,7 @@ stl = STL(
 )
 result = stl.fit()
 
-smoothed = lowess(df['值'], df.index, frac=fraction)
+smoothed = lowess(df['值'], np.arange(len(df)), frac=fraction)
 
 trend_lowess = smoothed[:, 1]