(超实用)京东订单数据分析案例-维度下钻

1,数据介绍,字段了解

尽可能熟悉业务,多知道字段的含义,字段字段间的逻辑关系,后期数据分析思路才能更清晰,结果才能更准确

c7fc4fcab42e43178864ecefc0377264.png

2,订单数据分析基本思路

维度下钻

e065a34b8f004fc7a04cdfca786a5200.png

 

3,代码实现全流程+思路

导包+绘图报错

import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns 
from scipy import stats
#加上了绘图-全局使用中文+解决中文报错的代码
from matplotlib.ticker import FuncFormatter
plt.rcParams['font.sans-serif']=['Arial Unicode MS']import warnings
warnings.filterwarnings('ignore')

读取数据,观察表格特点(间隔符)

#虽然直接打开的文件显得很乱,需要去发现还是以/t作为分隔符的
order = 'course_order_d.csv'
df = pd.read_csv(order,sep='\t', encoding="utf-8", dtype=str)

数据简单查看

df.head()#查看数据是否为空+数据类型
df.info()

5c2ba15c46624187a849bd05edf5a4bd.png

数据清洗+预处理

#说明都是2020-5-25下的订单
df['sale_ord_tm'].unique()#都是object,所以先转化类型,再进行数据预处理
df['sale_qtty'] = df['sale_qtty'].astype('int')
df['sale_ord_valid_flag'] = df['sale_ord_valid_flag'].astype('int')
df['cancel_flag'] = df['cancel_flag'].astype('int')
df['self_ord_flag'] = df['self_ord_flag'].astype('int')df['before_prefr_unit_price'] = df['before_prefr_unit_price'].astype('float')
df['after_prefr_unit_price'] = df['after_prefr_unit_price'].astype('float')
df['user_actual_pay_amount'] = df['user_actual_pay_amount'].astype('float')
df['total_offer_amount'] = df['total_offer_amount'].astype('float')#pd.to_datetime()它可以用于将字符串或数字转换为日期时间对象,还可以用于自动识别和调整日期时间。如果原始数据包含非标准的日期时间表示形式,则这个函数会更加有用
df.loc[:,'check_account_tm '] = pd.to_datetime(df.loc[:,'check_account_tm'])
df.loc[:,'sale_ord_tm'] = pd.to_datetime(df.loc[:,'sale_ord_tm'])
df.loc[:,'sale_ord_dt'] = pd.to_datetime(df.loc[:,'sale_ord_dt'])#个数/类型检查
df.info()df.head()#异常处理
#优惠前冰箱的最低价格是288,低于这个价格为异常值
(df.loc[:,'before_prefr_unit_price']<288).sum()#确认优惠后价格,实际支付价格,总优惠金额 不是小于0的
(df.loc[:,'after_prefr_unit_price']<0).sum()(df.loc[:,'user_actual_pay_amount']<0).sum()(df.loc[:,'total_offer_amount']<0).sum()print('删除异常值前',df.shape)
#去掉异常值
df=df[df['before_prefr_unit_price']>=288]
print('删除异常值后:',df.shape)#确保每个订单都是唯一的
#唯一属性订单ID-去重
df.drop_duplicates(subset=['sale_ord_id'],keep='first',inplace=True)
df.info()df.head()df.isnull().sum().sort_values(ascending=False)
#空值处理-补值
df.user_site_city_id=df.user_site_city_id.fillna('Not Given')
df.user_site_province_id=df.user_site_province_id.fillna('Not Given')#查看数值型字段的数据特征
df.describe()#再次检查空值/类型
df.info()#+字段=逻辑处理
df['total_actual_pay']=df['sale_qtty']*df['after_prefr_unit_price']
df#检查,空值,字段,类型
df.info()

宏观分析

#取消订单数量
order_cancel=df[df.cancel_flag==1]['sale_ord_id'].count()
order_cancel#订单数量
order_num=df['sale_ord_id'].count()
order_numorder_cancel/order_num# 解决matplotlib中文乱码matplotlib.rcParams['font.sans-serif'] = ['SimHei']
matplotlib.rcParams['font.serif'] = ['SimHei']
matplotlib.rcParams['axes.unicode_minus'] = Falselabels=['取消','未取消']
X=[order_cancel,order_num-order_cancel]
fig=plt.figure()
plt.pie(X,labels=labels,autopct='%1.2f%%')
plt.title('订单总数')
#取消未取消差不多3:7

a54619dfb2564a04a0bb79c9ce4a5df2.png

#求有效订单中,支付,未支付
df2=df.copy()
#只包含有效订单
df2=df2[(df2['sale_ord_valid_flag']==1)&(df2['cancel_flag']==0)&('before_prefr_unit_price'!=0)]#有效订单数量
order_valid=df2['sale_ord_id'].count()
order_valid#支付订单数量
order_payed=df2['sale_ord_id'][df2['user_actual_pay_amount']!=0].count()
order_payed#未支付订单数量
order_unpay=df2['sale_ord_id'][df2['user_actual_pay_amount']==0].count()
order_unpayorder_unpay/order_payedlabels=['支付','未支付']
Y=[order_payed,order_unpay]
fig=plt.figure()
plt.pie(Y,labels=labels,autopct='%1.2f%%')
plt.title('有效订单总数')

61babe40e74d4f08a62e06a74d31f11f.png

#订单的价格分布
price_series=df2['after_prefr_unit_price']
price_seriesprice_series_num=price_series.count()
hist,bin_edges=np.histogram(price_series,bins=80)
hist_sum=np.cumsum(hist)
hist_per=hist_sum/price_series_numprint('hist:{}'.format(hist))
print('*'*100)
print('bin_edges:{}'.format(bin_edges))
print('*'*100)
print('hist_sum:{}'.format(hist_sum))hist_perbin_edges_plot=np.delete(bin_edges,0)plt.figure(figsize=(20,8),dpi=80)
plt.xlabel('订单价格')
plt.ylabel('百分比')plt.style.use('ggplot')def to_percent(temp,position):return '%1.0f'%(100*temp)+'%'
plt.gca().yaxis.set_major_formatter(FuncFormatter(to_percent))
plt.plot(bin_edges_plot,hist_per,color='blue')

 

e4e0dee596244d7db934a2e81a6e8112.png

宏观分析结束,到微观分析啦

不同时间的有效订单数

df3=df2.copy()
df3['order_time_hms']=df3['sale_ord_tm'].apply(lambda x:x.strftime('%H:00:00'))
df3pay_time_df=df3.groupby('order_time_hms')['sale_ord_id'].count()
pay_time_dfx = pay_time_df.index
y = pay_time_df.valuesplt.figure(figsize=(20,8),dpi=80)
plt.style.use('ggplot')
plt.xlabel('时间')
plt.ylabel("有效订单量")
plt.xticks(range(len(x)), x, rotation=90)
rect = plt.bar(x, y, width=0.3, color=['#6699CC'])

62dc6fd7ec21483e964a6a03a9c9f7bd.png

0点订单量最多,怀疑是不是单人下单多,下一步人均订单数

import pandas as pd# 假设 df3 是你的原始 DataFrame
# 对 sale_ord_id 列按 order_time_hms 分组并计算计数
grouped = df3.groupby('order_time_hms')['sale_ord_id']# 获取分组后的计数结果,如果是 Series,则转换为 DataFrame
result_series = grouped.agg('count')
if isinstance(result_series, pd.Series):result_df = result_series.to_frame()
else:result_df = result_series# 重命名列
order_time_df = result_df.rename(columns={'sale_ord_id': 'order_num'})# 打印结果
print(order_time_df)
import pandas as pd# 假设 df3 是你的原始 DataFrame
# 对 user_log_acct 列按 order_time_hms 分组并计算每个组中唯一用户的数量
grouped = df3.groupby('order_time_hms')['user_log_acct']# 获取分组后的唯一用户数量结果,如果是 Series,则转换为 DataFrame
result_series = grouped.agg('nunique')
if isinstance(result_series, pd.Series):user_time_df = result_series.to_frame()
else:user_time_df = result_series# 重命名列
user_time_df = user_time_df.rename(columns={'user_log_acct': 'user_num'})# 打印结果
print(user_time_df)

739931ca751444a29f4ea9862b360895.png66ff0967bb234ef98404b0b8d450226d.png

order_num_per_user = order_time_df['order_num'] / user_time_df['user_num']x = order_num_per_user.index
y = order_num_per_user.valuesplt.figure(figsize=(20,8),dpi=80)
plt.style.use('ggplot')
plt.xlabel('时间')
plt.ylabel("人均有效订单量")
plt.xticks(range(len(x)),x,rotation=90)
plt.plot(x, y)

2e30780085d94adcb6e778d61723b3b4.png

虽然0点订单量还是最多,有些波动,继续求客单价vs平均订单价格

客单价(销售额/顾客数)和平均订单价格(销售额/订单数)

import pandas as pd# 假设 df3 是你的原始 DataFrame
# 对 total_actual_pay 列按 order_time_hms 分组并计算每个组的总和
grouped = df3.groupby('order_time_hms')['total_actual_pay']# 获取分组后的总和结果
result_series = grouped.agg('sum')# 将结果转换为 DataFrame
if isinstance(result_series, pd.Series):total_pay_time_df = result_series.to_frame()
else:total_pay_time_df = result_series# 重命名列
total_pay_time_df = total_pay_time_df.rename(columns={'total_actual_pay': 'total_pay'})# 打印结果
print(total_pay_time_df)

98ede200f73440cea3b1c99e03686f50.png

pay_per_user=total_pay_time_df['total_pay']/user_time_df['user_num']
pay_per_order=total_pay_time_df['total_pay']/order_time_df['order_num']x=pay_per_user.index
y=pay_per_user.values
y2=pay_per_order.valuesplt.figure(figsize=(20,8),dpi=80)
plt.style.use('ggplot')
plt.xlabel('时间')
plt.ylabel("价格")
plt.xticks(range(len(x)),x,rotation=90)plt.plot(x, y, color='red',linewidth=2.0,linestyle='--')
plt.plot(x, y2, color='blue',linewidth=3.0,linestyle='-.')
plt.legend(['客单价','平均订单价'])

dd156136e22a49c696470af7064d4d60.png

观察发现0点订单量最多,随后波动下滑,20点后开始平稳,是什么原因,继续研究是不是跟订单价格相关

df4=df3.copy()
df5=df3.copy()df4 = df4[df4['order_time_hms'] == '00:00:00']
df5 = df5[df5['order_time_hms'] == '20:00:00']def plot_acc_line(price_series, bin_num):len = price_series.count()hist, bin_edges = np.histogram(price_series, bins=bin_num) #生成直方图函数hist_sum = np.cumsum(hist)hist_per = hist_sum / len * 100hist_per_plot = np.insert(hist_per, 0, 0)plt.figure(figsize=(20,8), dpi=80)plt.xlabel('订单价格')plt.ylabel('百分比')plt.plot(bin_edges, hist_per_plot, color='blue')# 0时价格累积分布折线图price_series_0 = df4['after_prefr_unit_price']
plot_acc_line(price_series_0, 100)# 20时价格累积分布折线图,说明价格不是很大影响price_series_20 = df5['after_prefr_unit_price']
plot_acc_line(price_series_0, 100)

8b7a27a815bf4c54b8ae78138b25e7f1.png

似乎和价格关联不大,那会不会和优惠相关呢,继续分析

0时和其他时间的优惠占比

#验证是不是和优惠相关
#0时的优惠订单数
offer_order_0=df4['sale_ord_id'][df4['total_offer_amount']>0].count()
#0时订单数
order_num_0=df4['sale_ord_id'].count()
#0时优惠订单比
offer_order_per_0=offer_order_0/order_num_0
print('0时的优惠订单数:{}, 0时的订单数:{}, 优惠订单比例:{}'.format(offer_order_0, order_num_0, offer_order_per_0))#全部优惠订单数
offer_order_all=df3['sale_ord_id'][df3['total_offer_amount']>0].count()
#全部订单数
order_all=df3['sale_ord_id'].count()
#其他时间优惠订单数
offer_order_other=offer_order_all - offer_order_0
#其他时间订单数
order_num_other=order_all-order_num_0
offer_order_per_other=offer_order_other/order_num_other
print('其他时间的优惠订单数:{}, 其他时间的订单数:{}, 其他时间优惠订单比例:{}'.format(offer_order_other, order_num_other, offer_order_per_other))#0时,和其他时间的优惠订单占比对比
plt.figure(figsize=(8,6),dpi=80)
N=2
index=('0时','除了0时之外')
data=(offer_order_per_0,offer_order_per_other)
width=0.35
plt.ylabel("优惠订单占比")def to_percent(temp, position):return '%1.0f'%(100*temp) + '%'
plt.gca().yaxis.set_major_formatter(FuncFormatter(to_percent))p2 = plt.bar(index, data, width, color='#6699CC')

615cb3e2ac244d8d8634668f2c23008e.png

那会不会这个时间的某个优惠太多导致占比太大呢,继续求0时平均优惠占比 vs 其他时间平均优惠占比

import pandas as pd# 假设 df3 是你的原始 DataFrame
# 对 user_log_acct 列按 order_time_hms 分组并计算每个组中唯一用户的数量
grouped = df3.groupby('order_time_hms')['total_offer_amount']# 获取分组后的唯一用户数量结果,如果是 Series,则转换为 DataFrame
result_series = grouped.agg('sum')
if isinstance(result_series, pd.Series):user_time_df = result_series.to_frame()
else:user_time_df = result_series# 重命名列
total_pay_time_df = user_time_df.rename(columns={'order_time_hms': 'total_offer_amount'})# 打印结果
print(total_pay_time_df)offer_amount_0=total_pay_time_df['total_offer_amount'][0]
offer_amount_other=total_pay_time_df[1:].apply(lambda x:x.sum())['total_offer_amount']offer_amount_0_avg=offer_amount_0/offer_order_0
offer_amount_other_avg=offer_amount_other/offer_order_other
print('0时平均优惠价格:{}, 其他时间平均优惠价格:{}'.format(offer_amount_0_avg, offer_amount_other_avg))#0时和其他时间的平均优惠价格对比:可视化
plt.figure(figsize=(8, 6), dpi=80)
N = 2
index = ('0时', '除了0时以外')values = (offer_amount_0_avg, offer_amount_other_avg)
width = 0.35plt.ylabel("平均优惠价格/元")p2 = plt.bar(index, values, width, color='#6699CC')

2dadfd952d4e473e8c10770debce6d52.png

确认0时订单量大与优惠金额相关,接下来从地区维度拆分

df6=df2.copy()order_area_df=df6.groupby('user_site_province_id',as_index=False)['sale_ord_id'].agg('count')
order_area_dfimport pandas as pd# 假设 df3 是你的原始 DataFrame
# 对 user_log_acct 列按 order_time_hms 分组并计算每个组中唯一用户的数量
grouped = df6.groupby('user_site_province_id',as_index=False)['sale_ord_id']# 获取分组后的唯一用户数量结果,如果是 Series,则转换为 DataFrame
result_series = grouped.agg('count')
if isinstance(result_series, pd.Series):user_time_df = result_series.to_frame()
else:user_time_df = result_series# 重命名列
order_area_df = user_time_df.rename(columns={'sale_ord_id': 'order_num'})# 打印结果
print(order_area_df)order_area_df.drop([34],inplace=True)
order_area_df['province_id']=order_area_df['user_site_province_id'].astype('int')
order_area_dfcity = 'city_level.csv'
df_city = pd.read_csv(city,sep = ',', encoding="gbk", dtype=str)
df_city['province_id'] = df_city['province_id'].astype('int')
df_city#省份去重
df_city=df_city.drop_duplicates(subset=['province_id'],keep='first')
df_citydf_city=df_city[['province_id','dim_province_name']].sort_values(by='province_id',ascending=True).reset_index()
df_city.drop(['index'],axis=1,inplace=True)
df_cityorder_province_df=pd.merge(order_area_df,df_city,on='province_id').sort_values(by='order_num',ascending=False)
order_province_df

b9c901699e4b49fdad4b44730bded6a5.png

各个省份订单量

#有效订单量
plt.style.use('ggplot')x = order_province_df['dim_province_name']
y = order_province_df['order_num']plt.figure(figsize=(20,8),dpi=80)
plt.style.use('ggplot')
plt.xlabel('时间')
plt.ylabel("有效订单量")
plt.xticks(range(len(x)), x, rotation=90)
rect = plt.bar(x, y, width=0.3, color=['#6699CC'])#有效订单量-饼图
plt.figure(figsize=(6,9)) 
labels = order_province_df['dim_province_name']plt.pie(order_province_df['order_num'], labels=labels,autopct='%1.2f%%') # autopct :控制饼图内百分比设置, '%1.1f'指小数点前后位数(没有用空格补齐);plt.axis('equal')
plt.show()

ebdc4d0fb0cb40b68305adcee0780833.png

4ba7625de44348f6829854c09b4cd28c.png

怕一个客订单多,求各省份客单价对比

#各省份客单价对比cust_price_df = df6.groupby('user_site_province_id', as_index=False)['total_actual_pay'].agg({'total_pay':'sum'})
cust_price_df.columns = ['province_id','total_pay']
cust_price_df.drop([34], inplace=True)
cust_price_df['province_id'] = cust_price_df['province_id'].astype('int')
cust_price_df = pd.merge(cust_price_df, df_city, on='province_id').sort_values(by='total_pay', ascending=False)
cust_price_df['order_num'] = order_province_df['order_num']cust_df = df6.groupby('user_site_province_id', as_index=False)['user_log_acct'].agg({'user_num':'nunique'})
cust_df.columns = ['province_id','user_num']
cust_df.drop([34], inplace=True)
cust_df['province_id'] = cust_df['province_id'].astype('int')cust_price_df = pd.merge(cust_price_df, cust_df, on='province_id')
cust_price_df['cust_price'] = cust_price_df['total_pay'] / cust_price_df['user_num'] #计算客单价
cust_price_df = cust_price_df.sort_values(by='order_num', ascending=False)
cust_price_df = cust_price_df[:10]
cust_price_df = cust_price_df.sort_values(by='cust_price', ascending=False)cust_price_df

2ad9d93b52734828a4c64998e535bae8.png

plt.style.use('ggplot')x = cust_price_df['dim_province_name']
y = cust_price_df['cust_price']plt.figure(figsize=(20,8),dpi=80)
plt.style.use('ggplot')
plt.xlabel('时间')
plt.ylabel("客单价")
rect = plt.bar(x, y, width=0.3, color=['#6699CC'])

259170a97af44750b64b42ba31f1b26d.png

可能客单价大的订单数小,可能客单价小的订单数多,气泡图显示

import matplotlib.pyplot as plt
import seaborn as snsplt.figure(figsize=(15, 10))x = cust_price_df['cust_price']
y = cust_price_df['order_num']# Calculate the minimum and maximum sizes based on your data
min_size = min(cust_price_df['cust_price']) * 3
max_size = max(cust_price_df['cust_price']) * 3# Use the calculated sizes for the scatterplot
ax = sns.scatterplot(x=x, y=y, hue=cust_price_df['dim_province_name'], palette=['#6699CC'], sizes=(min_size, max_size), size=x*3, legend=False)ax.set_xlabel("客单价", fontsize=12)
ax.set_ylabel("订单数量", fontsize=12)province_list = [3, 5, 2, 1, 6, 7, 4, 9, 0, 11]# Adding text on top of the bubbles
for line in province_list:ax.text(x[line], y[line], cust_price_df['dim_province_name'][line], horizontalalignment='center', size='large', color='black', weight='semibold')plt.show()

fc4882042b9e4ede916b8b9dd8d09a65.png

知道上海虽然客单价高2600左右,但是订单数量少600左右

广东订单数量多1800左右,客单价在2000左右

下一步,看头部省份的四个品牌的渗透率

#不同品牌的产品单价
df7 = df2.copy()brand_sale_df=df7.groupby('brandname',as_index=False).agg({'total_actual_pay':'sum','sale_qtty':'sum'}).sort_values(by='total_actual_pay',ascending=False)
brand_sale_dfdf8 = df7.copy()df8 = df8[df8['user_site_province_id'] == '1'] # 省份取北京,数字是省份idbrand_sale_df_bj = df8.groupby('brandname', as_index=False).agg({'total_actual_pay':'sum', 'sale_qtty':'sum'}).sort_values(by='total_actual_pay', ascending=False)
brand_sale_df_bj = brand_sale_df_bj[(brand_sale_df_bj['brandname'] == '海尔(Haier)')|(brand_sale_df_bj['brandname'] == '容声(Ronshen)')|(brand_sale_df_bj['brandname'] == '西门子(SIEMENS)')|(brand_sale_df_bj['brandname'] == '美的(Midea)')]
brand_sale_df_bjdf8=df7.copy()
df8=df8[df8['brandname']=='海尔(Haier)']brand_sale_df_haier=df8.groupby('user_site_province_id',as_index=False).agg({'total_actual_pay':'sum','sale_qtty':'sum'}).sort_values(by='total_actual_pay',ascending=False)
brand_sale_df_haier = brand_sale_df_haier[(brand_sale_df_haier['user_site_province_id'] == '1')|(brand_sale_df_haier['user_site_province_id'] == '2')|(brand_sale_df_haier['user_site_province_id'] == '12')|(brand_sale_df_haier['user_site_province_id'] == '22')|(brand_sale_df_haier['user_site_province_id'] == '19')]
brand_sale_df_haier['user_site_province_id'] = brand_sale_df_haier['user_site_province_id'].astype('int')
brand_sale_df_haier.columns = ['province_id','total_actual_pay', 'sale_qtty']
brand_sale_df_haier.sort_values(by='province_id')

11ffc2602ebf4ac1882197e9afb89eb4.png

cust_price_df

5c522757a89348f4b5866d3113aa31c1.png

order_num_df = cust_price_df[['province_id', 'order_num']][(cust_price_df['province_id'] == 1)|(cust_price_df['province_id'] == 12)|(cust_price_df['province_id'] == 19)|(cust_price_df['province_id'] == 2)|(cust_price_df['province_id'] == 22)]
order_num_df = order_num_df.sort_values(by='province_id')
order_num_df

4346d6ab5f1f45ec8721a8a49d0f4f95.png

渗透率

def province_shentou(df, brandname, cust_price_df):df = df[df['brandname'] == brandname]brand_sale_df = df.groupby('user_site_province_id', as_index=False).agg({'total_actual_pay':'sum', 'sale_qtty':'sum'}).sort_values(by='total_actual_pay', ascending=False)brand_sale_df = brand_sale_df[(brand_sale_df['user_site_province_id'] == '1')|(brand_sale_df['user_site_province_id'] == '2')|(brand_sale_df['user_site_province_id'] == '12')|(brand_sale_df['user_site_province_id'] == '22')|(brand_sale_df['user_site_province_id'] == '19')]brand_sale_df['user_site_province_id'] = brand_sale_df['user_site_province_id'].astype('int')brand_sale_df.columns = ['province_id','total_actual_pay', 'sale_qtty']brand_sale_df.sort_values(by='province_id')order_num = cust_price_df[['province_id', 'order_num']][(cust_price_df['province_id'] == 1)|(cust_price_df['province_id'] == 12)|(cust_price_df['province_id'] == 19)|(cust_price_df['province_id'] == 2)|(cust_price_df['province_id'] == 22)]order_num = order_num.sort_values(by='province_id')brand_sale_df = pd.merge(brand_sale_df, order_num_df, on='province_id')brand_sale_df['渗透率'] = brand_sale_df['sale_qtty'] / brand_sale_df['order_num']#销售数量/订单数量brand_sale_df = brand_sale_df.sort_values(by='province_id')return brand_sale_dfdf9 = df7.copy()brand_sale_df_rs = province_shentou(df9, '容声(Ronshen)', cust_price_df)
brand_sale_df_siem = province_shentou(df9, '西门子(SIEMENS)', cust_price_df)
brand_sale_df_mi = province_shentou(df9, '美的(Midea)', cust_price_df)
brand_sale_df_haier = province_shentou(df9, '海尔(Haier)', cust_price_df)brand_sale_df_siem

14c821a5f37048d6a2c844e7c5c74eed.png

plt.style.use('ggplot')x = np.arange(5)y1 = brand_sale_df_siem['渗透率']
y2 = brand_sale_df_rs['渗透率']
y3 = brand_sale_df_haier['渗透率']
y4 = brand_sale_df_mi['渗透率']tick_label=['北京', '上海', '江苏', '广东', '四川']total_width, n = 0.8, 4
width = total_width / n
x = x - (total_width - width) / 2plt.figure(figsize=(20,8),dpi=80)
plt.style.use('ggplot')
plt.ylabel("渗透率")bar_width = 0.2
plt.bar(x, y1, width=bar_width, color=['red'])
plt.bar(x+width, y2, width=bar_width, color=['yellow'])
plt.bar(x+2*width, y3, width=bar_width, color=['green'])
plt.bar(x+3*width, y4, width=bar_width, color=['blue'])plt.xticks(x+bar_width/2, tick_label) # 显示x坐标轴的标签,即tick_label,调整位置,使其落在两个直方图中间位置

5b8f032e93d5416089aa7cae4da570a8.png

求各个品牌的客单价

plt.style.use('ggplot')brand_sale_df['单价'] = brand_sale_df['total_actual_pay'] / brand_sale_df['sale_qtty']
brand_sale_df = brand_sale_df.sort_values(by='单价', ascending=False)x = brand_sale_df['brandname']
y = brand_sale_df['单价']plt.figure(figsize=(20,8),dpi=80)
plt.style.use('ggplot')
plt.xlabel('品牌')
plt.ylabel("客单价")plt.xticks(range(len(x)), x, rotation=90)
rect = plt.bar(x, y, width=0.6, color=['#6699CC'])plt.show()

d1594315c9374e71a4c75755d1f66173.png

4,总结

1e76ea10d781479899b6be665b985688.png

(交个朋友/技术接单/ai办公/性价比资源)

9fbb952aaa304c2dbcb1c743056ab15e.png

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/19821.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

华为telnet的两种认证方式

华为telnet的两种认证方式 实验拓扑&#xff1a; 实验要求&#xff1a; 1.采用普通密码认证实现telnet 远程登录机房设备R3 2.采用AAA认证服务方式实现telnet 远程登录机房设备R3 实验步骤&#xff1a; 1.完成基本配置&#xff08;设备接口配置IP&#xff0c;此步骤略过&#…

Facebook的隐私保护挑战:用户数据安全的新时代

在全球范围内&#xff0c;Facebook已经成为了不可忽视的社交媒体巨头&#xff0c;它连接着超过20亿的活跃用户。然而&#xff0c;随着其影响力的不断扩大&#xff0c;关于用户隐私和数据安全的问题也愈加引人关注。本文将深入探讨Facebook面临的隐私保护挑战&#xff0c;以及它…

解析前端开发中同源策略与配置代理

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、pandas是什么&#xff1f;二、使用步骤 1.引入库2.读入数据总结 前言 在前端开发中&#xff0c;跨域请求是一个常见的问题。同源策略限制了浏览器中一个页面…

Unity中的MVC框架

基本概念 MVC全名是Model View Controller 是模型(model)-视图(view)-控制器(controller)的缩写 是一种软件设计规范&#xff0c;用一种业务逻辑、数据、界面显示 分离的方法组织代码 将业务逻辑聚集到一个部件里面&#xff0c;在改进和个性化定制界面及用户交互的同时&#x…

【嵌入式硬件】DRV8874电机驱动

目录 1 芯片介绍 1.1 特性简介 1.2 引脚配置 1.3 最佳运行条件 2 详细说明 2.1 PMODE配置控制模式 2.1.1 PH/EN 控制模式 2.1.2 PWM 控制模式 2.1.3 独立半桥控制模式 2.2 电流感测和调节 2.2.1 IPROPI电流感测 2.2.2 IMODE电流调节 3.应用 3.1设计要求 3.2 设计…

AI换脸FaceFusion一键云部署指南

大家好&#xff0c;从我开始分享到现在&#xff0c;收到很多朋友的反馈说配置很低玩不了AI。本篇是一个云端部署AI项目的指南&#xff0c;帮助大家在云端进行AI项目的部署。我会从云平台的选择、代码部署、保存镜像几个方面进行详细的介绍。没有代码基础的小白也不用担心&#…

乐观锁 or 悲观锁 你怎么选?

你有没有听过这样一句话&#xff1a;悲观者正确&#xff0c;乐观者成功​。那么今天我来分享下什么是乐观锁​和悲观锁。 乐观锁和悲观锁有什么区别&#xff0c;它们什么场景会用 乐观锁 乐观锁基于这样的假设&#xff1a;多个事务在同一时间对同一数据对象进行操作的可能性很…

工厂模式详情

一.介绍工厂模式的用途与特点 工厂方法模式是一种创建型设计模式&#xff0c; 其在父类中提供一个创建对象的方法&#xff0c; 允许子类决定实例化对象的类型。定义工厂方法模式(Fatory Method Pattern)是指定义一个创建对象的接口&#xff0c;但让实现这个接口的类来决定实例…

Python导出Jira列表

import requests import urllib3 urllib3.disable_warnings() from jira import JIRA import pandas as pd def login_jira(username,password):jira JIRA("https://jira.cn/",basic_auth(username,password))#projectsjira.project(id13)# jqlproject"云链-…

基于强化学习的控制率参数自主寻优

1.介绍 针对控制建模与设计场景中控制参数难以确定的普遍问题&#xff0c;提出了一种基于强化学习的控制律参数自主优化解决方案。该方案以客户设计的控制律模型为基础&#xff0c;根据自定义的控制性能指标&#xff0c;自主搜索并确定最优的、可状态依赖的控制参数组合。 可…

unity打包的WebGL部署到IIS问题

部署之后会出错&#xff0c;我遇到的有以下几种&#xff1b; 进度条卡住不动 明明已经部署到了IIS上&#xff0c;为什么浏览网页的时候还是过不去或者直接报错。 进度条卡住不动的问题其实就是wasm和data的错误。 此时在浏览器上按F12进入开发者模式查看错误&#xff08;下图…

付费工具逻辑

1.付费推广目的&#xff1a; 传播信息心理暗示&#xff1b;扩大销售&#xff0c;指导消费&#xff1b;树立形象&#xff0c;塑道品牌&#xff1b; 2.付费和免费广告&#xff1a; 付费主要为了增加曝光&#xff1b;免费广告一般比付费广告转化率高&#xff1b; 3.平台广告交…

《Kubernetes部署篇:基于麒麟V10+ARM64架构部署harbor v2.4.0镜像仓库》

总结&#xff1a;整理不易&#xff0c;如果对你有帮助&#xff0c;可否点赞关注一下&#xff1f; 更多详细内容请参考&#xff1a;企业级K8s集群运维实战 一、环境信息 K8S版本 操作系统 CPU架构 服务版本 1.26.15 Kylin Linux Advanced Server V10 ARM64 harbor v2.4.0 二、部…

chrome谷歌浏览器开启Gemini Nano模型

前提 确保您的操作系统语言设置为英语(美国) 可能还需要将 Chrome 浏览器的语言更改为英语(美国)。 下载dev或Canary版本Chrome Chrome Canary Chrome Dev 注意:确认您的版本高于 127.0.6512.0。 其中一个Chrome版本不行就切换另外一个版本 绕过性能检查 Tab输入: …

结构体相关习题的补充

结构体相关习题的补充 题目1&#xff1a; 如有以下代码&#xff1a; struct student {int num;char name[32];float score; }stu;则下面的叙述不正确的是&#xff1a;( ) A.struct 是结构体类型的关键字 B.struct student 是用户定义的结构体类型 C.num, score 都是结构体…

正邦科技(day4)

烧录 一、烧录固件二、 通讯模块升级1&#xff1a;USB的方式升级固件2&#xff1a;通过mqtt的方式升级固件3&#xff1a;切换环境 三、 烧录WiFi1&#xff1a;短接2&#xff1a;烧录脚本 设备注意事项&#xff1a; 第一种方式&#xff1a;通信模组和MCU都可以统一烧录BoodLoade…

Oracle Hint /*+APPEND*/插入性能总结

oracle append用法 Oracle中的APPEND用法主要用于提高数据插入的效率。 基本用法&#xff1a;在使用了APPEND选项后&#xff0c;插入数据会直接加到表的最后面&#xff0c;而不会在表的空闲块中插入数据。这种做法不需要寻找freelist中的free block&#xff0c;从而避免了在…

【计算机毕设】基于Spring Boot的课程作业管理系统 - 源码免费(私信领取)

免费领取源码 &#xff5c; 项目完整可运行 &#xff5c; v&#xff1a;chengn7890 诚招源码校园代理&#xff01; 1. 研究目的 课程作业管理系统旨在为教师和学生提供一个便捷的平台&#xff0c;用于发布、提交和评定课程作业。本系统旨在提高作业管理的效率&#xff0c;促进教…

Golang反射

文章目录 基本介绍reflect包reflect.Typereflect.Valuereflect.Kind具体类型、空接口与reflect.Value的相互转换 反射应用场景修改变量的值访问结构体的字段信息调用变量所绑定的方法实现函数适配器创建任意类型的变量 基本介绍 基本介绍 在Go中&#xff0c;反射&#xff08;re…

错误 0x80070570:文件或目录损坏且无法读取/无法访问[拒绝访问]-解决方法

1.起因&#xff1a;在挪动&#xff35;盘文件时&#xff0c;出现无法移动的报错提示&#xff1a; and无法访问[拒绝访问]: 2.原因&#xff3b;大多是胡乱拔出&#xff35;盘&#xff3d; &#xff3b;来自0x80070570 文件或目录损坏且无法读取 CHKDSK 修复方法-CSDN博客&#…