update
This commit is contained in:
parent
c28d32491a
commit
0888cc88fc
@ -369,17 +369,19 @@ async def scatter_model(
|
||||
resp['label'].append(f'[{quota_interval_arr[i]},{v})')
|
||||
bins.append(v)
|
||||
|
||||
summary_data = None
|
||||
# todo 整体的,需要补充分组的
|
||||
for key, tmp_df in df.groupby('date'):
|
||||
bins_s = pd.cut(tmp_df['values'], bins=bins,
|
||||
right=False).value_counts()
|
||||
bins_s.sort_index(inplace=True)
|
||||
total = int(bins_s.sum())
|
||||
resp['list'][key.strftime('%Y-%m-%d')] = {'n': bins_s.to_list(), 'total': total,
|
||||
'p': round(bins_s * 100 / total, 2).to_list()}
|
||||
'p': round(bins_s * 100 / total, 2).to_list()}
|
||||
return schemas.Msg(code=0, msg='ok', data=resp)
|
||||
|
||||
if interval_type == 'def' and analysis == 'number_of_days':
|
||||
resp = {}
|
||||
resp = {'list': {}}
|
||||
for key, tmp_df in df.groupby('date'):
|
||||
total = int(tmp_df['values'].sum())
|
||||
resp['list'][key.strftime('%Y-%m-%d')] = {'n': total, 'total': total, 'p': 100}
|
||||
|
@ -299,12 +299,15 @@ ORDER BY level
|
||||
event_name_col == event_name
|
||||
|
||||
]
|
||||
values_col = func.count().label('values')
|
||||
if analysis in ['number_of_days', 'number_of_hours']:
|
||||
values_col = func.count(func.distinct(e_account_id_col)).label('values')
|
||||
|
||||
if analysis in ['times', 'number_of_days', 'number_of_hours']:
|
||||
|
||||
qry = sa.select(event_date_col, func.count().label('values')) \
|
||||
qry = sa.select(event_date_col, values_col) \
|
||||
.where(and_(*where)) \
|
||||
.group_by(event_date_col, e_account_id_col)
|
||||
.group_by(event_date_col, *self.groupby, e_account_id_col)
|
||||
|
||||
sql = str(qry.compile(compile_kwargs={"literal_binds": True}))
|
||||
print(sql)
|
||||
@ -319,7 +322,7 @@ ORDER BY level
|
||||
|
||||
qry = sa.select(event_date_col, settings.CK_FUNC[analysis](event_attr_col).label('values')) \
|
||||
.where(and_(*where)) \
|
||||
.group_by(event_date_col, e_account_id_col)
|
||||
.group_by(event_date_col, *self.groupby, e_account_id_col)
|
||||
sql = str(qry.compile(compile_kwargs={"literal_binds": True}))
|
||||
print(sql)
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user