From 5a6bd4ea02bb8a8b4a2f2f36a20cae7af929e9e0 Mon Sep 17 00:00:00 2001 From: wuaho Date: Wed, 22 Sep 2021 10:15:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=BB=84=E4=B8=8D=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api_v1/endpoints/query.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/api_v1/endpoints/query.py b/api/api_v1/endpoints/query.py index 8e0df31..bf0b9db 100644 --- a/api/api_v1/endpoints/query.py +++ b/api/api_v1/endpoints/query.py @@ -183,7 +183,7 @@ async def event_model( if last_value > 0: q['last_value'] = float(last_value) break - if groupby: + if groupby and (set(groupby) & set(df) == set(groupby)): q['date_range'] = [f'{i}' for i in df.set_index(groupby).index] else: q['date_range'] = ['合计'] @@ -191,7 +191,7 @@ async def event_model( res.append(q) continue - if groupby: + if groupby and (set(groupby) & set(df)) == set(groupby): # 有分组 for group, df_group in df.groupby(groupby): df_group.reset_index(drop=True, inplace=True) @@ -293,7 +293,7 @@ async def retention_model(request: Request, for i in set(date_range) - set(df.index): df.loc[i] = 0 df.sort_index(inplace=True) - days = [i for i in range(1,unit_num + 1)] + days = [i for i in range(1, unit_num + 1)] summary_values = {} today = datetime.datetime.today().date()