留存时长修复

This commit is contained in:
wuaho 2021-10-26 22:51:02 +08:00
parent 4e99e96228
commit 0cadeb283a

View File

@ -299,7 +299,7 @@ async def retention_model(request: Request,
for i in set(date_range) - set(df.index): for i in set(date_range) - set(df.index):
df.loc[i] = 0 df.loc[i] = 0
df.sort_index(inplace=True) df.sort_index(inplace=True)
days = [i for i in range(1, unit_num + 1)] days = [i for i in range(1, unit_num )]
summary_values = {} summary_values = {}
today = datetime.datetime.today().date() today = datetime.datetime.today().date()
@ -310,8 +310,8 @@ async def retention_model(request: Request,
tmp['n'] = [] tmp['n'] = []
tmp['p_outflow'] = [] tmp['p_outflow'] = []
tmp['n_outflow'] = [] tmp['n_outflow'] = []
for i in range(1, (today - date).days + 1): for i in range(1, (today - date).days):
if i > unit_num: if i >= unit_num:
break break
p = float(getattr(value, f'p{i + 1}')) p = float(getattr(value, f'p{i + 1}'))
n = int(getattr(value, f'cnt{i + 1}')) n = int(getattr(value, f'cnt{i + 1}'))