|
|
@@ -27,6 +27,7 @@ FROM (
|
|
|
SUM(CASE WHEN t1.remaining_amount_after_return >= 2000 THEN 1 ELSE 0 END) AS `2000+单数`
|
|
|
FROM sd_sales_order AS t1
|
|
|
LEFT JOIN sd_big_sales_order AS t2 ON t1.sale_id = t2.sale_id
|
|
|
+ where t1.remaining_amount_after_return > 0
|
|
|
GROUP BY t1.document_date
|
|
|
) AS temp;
|
|
|
"""
|
|
|
@@ -126,14 +127,22 @@ FROM (
|
|
|
df['单据日期'] = pd.to_datetime(df['单据日期'])
|
|
|
df = df.sort_values('单据日期').reset_index(drop=True)
|
|
|
|
|
|
- weekly_summary = df.groupby('第几周').agg({
|
|
|
- col: 'sum' for col in df.columns if col not in ['单据日期', '2000+单数占比', '第几周']
|
|
|
- }).reset_index()
|
|
|
+ # weekly_summary = df.groupby('第几周').agg({
|
|
|
+ # col: 'sum' for col in df.columns if col not in ['单据日期', '2000+单数占比', '第几周', '最大单件数', '最大单金额']
|
|
|
+ # }).reset_index()
|
|
|
+
|
|
|
+ # 修改后:
|
|
|
+ agg_dict = {col: 'sum' for col in df.columns if
|
|
|
+ col not in ['单据日期', '2000+单数占比', '第几周', '最大单件数', '最大单金额']}
|
|
|
+ agg_dict['最大单件数'] = 'max'
|
|
|
+ agg_dict['最大单金额'] = 'max'
|
|
|
+ weekly_summary = df.groupby('第几周').agg(agg_dict).reset_index()
|
|
|
|
|
|
weekly_summary['2000+单数'] = pd.to_numeric(weekly_summary['2000+单数'], errors='coerce')
|
|
|
weekly_summary['总单数'] = pd.to_numeric(weekly_summary['总单数'], errors='coerce')
|
|
|
weekly_summary['2000+单数占比'] = (weekly_summary['2000+单数'] / weekly_summary['总单数']).fillna(0).round(4)
|
|
|
|
|
|
+
|
|
|
new_data = []
|
|
|
current_week = None
|
|
|
|