# 计算总消费次数 total_consumption_times = len(kpidf) # 计算总月份数 total_months = len(pd.unique(kpidf['购药时间'].dt.month)) # 计算月均消费次数 average_consumption_times_per_month = total_consumption_times / total_months # 计算总消费金额 total_consumption_amount = df['实收金额'].sum() # 计算月消费金额 average_consumption_amount_per_month = total_consumption_amount / total_months # 绘制箱图 plt.boxplot(df['实收金额'][:100]) plt.show() print("月均消费次数:", average_consumption_times_per_month) print("月消费金额:", average_consumption_amount_per_month) [2025-04-17 16:51:27 | AI问答 | 168点数解答]