修改response
This commit is contained in:
parent
5c19f8ec24
commit
fa190dc1df
10
run.py
10
run.py
|
@ -16,10 +16,14 @@ TEXT = "text"
|
|||
app = Flask(__name__)
|
||||
|
||||
|
||||
def generate(data):
|
||||
def generate(data: pd.DataFrame):
|
||||
# 用 StringIO 在内存中写,不会生成实际文件
|
||||
out = io.StringIO()
|
||||
w = csv.writer(out)
|
||||
w.writerow(data.columns.tolist()) # 先写入表头
|
||||
yield out.getvalue()
|
||||
out.seek(0)
|
||||
out.truncate(0)
|
||||
for i in range(data.shape[0]): # 对于 data 中的每一条
|
||||
w.writerow(data.iloc[i].values.tolist()) # 传入的是一个数组 ['xxx','xxx@xxx.xxx'] csv.writer 会把它处理成逗号分隔的一行
|
||||
# 需要注意的是传入仅一个字符串 '' 时,会被逐字符分割,所以要写成 ['xxx'] 的形式
|
||||
|
@ -133,9 +137,7 @@ def run_ts_predict():
|
|||
try:
|
||||
data = pd.read_csv(data_file)
|
||||
logger.info(data.shape)
|
||||
rest = run_prophet(data, period=int(period), freq=freq)[[
|
||||
'ds', 'yhat'
|
||||
]]
|
||||
rest = run_prophet(data, period=int(period), freq=freq)
|
||||
logger.info(rest.columns)
|
||||
rest['ds'] = rest['ds'].apply(str)
|
||||
rest['yhat'] = rest['yhat'].apply(str)
|
||||
|
|
Loading…
Reference in New Issue