当前位置: 首页 > news >正文

如何快速进行网站开发手机百度旧版本下载

如何快速进行网站开发,手机百度旧版本下载,免费杂志排版软件,企业网站网页尺寸文章目录 1.数据加载2.查看数据情况3.数据合并及填充4.查看特征字段之间相关性5.聚合操作6.时间维度上看销售额7.计算用户RFM8.数据保存存储(1).to_csv(1).to_pickle 1.数据加载 import pandas as pd dataset pd.read_csv(SupplyChain.csv, encodingunicode_escape) dataset2…

文章目录

  • 1.数据加载
  • 2.查看数据情况
  • 3.数据合并及填充
  • 4.查看特征字段之间相关性
  • 5.聚合操作
  • 6.时间维度上看销售额
  • 7.计算用户RFM
  • 8.数据保存存储
    • (1).to_csv
    • (1).to_pickle


1.数据加载

import pandas as pd
dataset = pd.read_csv('SupplyChain.csv', encoding='unicode_escape')
dataset

在这里插入图片描述

2.查看数据情况

print(dataset.shape)
print(dataset.isnull().sum())

在这里插入图片描述

在这里插入图片描述

3.数据合并及填充

print(dataset[['Customer Fname', 'Customer Lname']])
#  fistname与lastname进行合并
dataset['Customer Full Name'] = dataset['Customer Fname'] +dataset['Customer Lname']
#dataset.head()
dataset['Customer Zipcode'].value_counts()
# 查看缺失值,发现有3个缺失值
print(dataset['Customer Zipcode'].isnull().sum())

在这里插入图片描述

dataset['Customer Zipcode'] = dataset['Customer Zipcode'].fillna(0)
dataset.head()

在这里插入图片描述

4.查看特征字段之间相关性

import matplotlib.pyplot as plt
import seaborn as sns
# 特征字段之间相关性 热力图
data = dataset
plt.figure(figsize=(20,10))
# annot=True 显示具体数字
sns.heatmap(data.corr(), annot=True, cmap='coolwarm')
# 结论:可以观察到Product Price和Sales,Order Item Total有很高的相关性

在这里插入图片描述

5.聚合操作

# 基于Market进行聚合
market = data.groupby('Market')
# 基于Region进行聚合
region = data.groupby('Order Region')
plt.figure(1)
market['Sales per customer'].sum().sort_values(ascending=False).plot.bar(figsize=(12,6), title='Sales in different markets')
plt.figure(2)
region['Sales per customer'].sum().sort_values(ascending=False).plot.bar(figsize=(12,6), title='Sales in different regions')
plt.show()

在这里插入图片描述
在这里插入图片描述

# 基于Category Name进行聚类
cat = data.groupby('Category Name')
plt.figure(1)
# 不同类别的 总销售额
cat['Sales per customer'].sum().sort_values(ascending=False).plot.bar(figsize=(12,6), title='Total sales')
plt.figure(2)
# 不同类别的 平均销售额
cat['Sales per customer'].mean().sort_values(ascending=False).plot.bar(figsize=(12,6), title='Total sales')
plt.show()

在这里插入图片描述

在这里插入图片描述

6.时间维度上看销售额

#data['order date (DateOrders)']
# 创建时间戳索引
temp = pd.DatetimeIndex(data['order date (DateOrders)'])
temp

在这里插入图片描述

# 取order date (DateOrders)字段中的year, month, weekday, hour, month_year
data['order_year'] = temp.year
data['order_month'] = temp.month
data['order_week_day'] = temp.weekday
data['order_hour'] = temp.hour
data['order_month_year'] = temp.to_period('M')
data.head()

在这里插入图片描述

# 对销售额进行探索,按照不同时间维度 年,星期,小时,月
plt.figure(figsize=(10, 12))
plt.subplot(4, 2, 1)
df_year = data.groupby('order_year')
df_year['Sales'].mean().plot(figsize=(12, 12), title='Average sales in years')
plt.subplot(4, 2, 2)
df_day = data.groupby('order_week_day')
df_day['Sales'].mean().plot(figsize=(12, 12), title='Average sales in days per week')
plt.subplot(4, 2, 3)
df_hour = data.groupby('order_hour')
df_hour['Sales'].mean().plot(figsize=(12, 12), title='Average sales in hours per day')
plt.subplot(4, 2, 4)
df_month = data.groupby('order_month')
df_month['Sales'].mean().plot(figsize=(12, 12), title='Average sales in month per year')
plt.tight_layout()
plt.show()

在这里插入图片描述

# 探索商品价格与 销售额之间的关系
data.plot(x='Product Price', y='Sales per customer') 
plt.title('Relationship between Product Price and Sales per customer')
plt.xlabel('Product Price')
plt.ylabel('Sales per customer')
plt.show()

在这里插入图片描述

7.计算用户RFM

# # 用户分层 RFM
data['TotalPrice'] = data['Order Item Quantity'] * data['Order Item Total']
data[['TotalPrice', 'Order Item Quantity', 'Order Item Total']]

在这里插入图片描述

# 时间类型转换
data['order date (DateOrders)'] = pd.to_datetime(data['order date (DateOrders)'])
# 统计最后一笔订单的时间
data['order date (DateOrders)'].max()

在这里插入图片描述

# 假设我们现在是2018-2-1
import datetime
present = datetime.datetime(2018,2,1)
# 计算每个用户的RFM指标
# 按照Order Customer Id进行聚合,
customer_seg = data.groupby('Order Customer Id').agg({'order date (DateOrders)': lambda x: (present-x.max()).days,                                                       'Order Id': lambda x:len(x), 'TotalPrice': lambda x: x.sum()})
customer_seg

在这里插入图片描述

# 将字段名称改成 R,F,M
customer_seg.rename(columns={'order date (DateOrders)': 'R_Value', 'Order Id': 'F_Value', 'TotalPrice': 'M_Value'}, inplace=True)
customer_seg.head()

在这里插入图片描述

# 将RFM数据划分为4个尺度
quantiles = customer_seg.quantile(q=[0.25, 0.5, 0.75])
quantiles = quantiles.to_dict()
quantiles

在这里插入图片描述

# R_Value越小越好 => R_Score就越大
def R_Score(a, b, c):if a <= c[b][0.25]:return 4elif a <= c[b][0.50]:return 3elif a <= c[b][0.75]:return 2else:return 1# F_Value, M_Value越大越好
def FM_Score(a, b, c):if a <= c[b][0.25]:return 1elif a <= c[b][0.50]:return 2elif a <= c[b][0.75]:return 3else:return 4
# 新建R_Score字段,用于将R_Value => [1,4]
customer_seg['R_Score']  = customer_seg['R_Value'].apply(R_Score, args=("R_Value", quantiles))
# 新建F_Score字段,用于将F_Value => [1,4]
customer_seg['F_Score']  = customer_seg['F_Value'].apply(FM_Score, args=("F_Value", quantiles))
# 新建M_Score字段,用于将R_Value => [1,4]
customer_seg['M_Score']  = customer_seg['M_Value'].apply(FM_Score, args=("M_Value", quantiles))
customer_seg.head()

在这里插入图片描述

# 计算RFM用户分层
def RFM_User(df):if df['M_Score'] > 2 and df['F_Score'] > 2 and df['R_Score'] > 2:return '重要价值用户'if df['M_Score'] > 2 and df['F_Score'] <= 2 and df['R_Score'] > 2:return '重要发展用户'if df['M_Score'] > 2 and df['F_Score'] > 2 and df['R_Score'] <= 2:return '重要保持用户'if df['M_Score'] > 2 and df['F_Score'] <= 2 and df['R_Score'] <= 2:return '重要挽留用户'if df['M_Score'] <= 2 and df['F_Score'] > 2 and df['R_Score'] > 2:return '一般价值用户'if df['M_Score'] <= 2 and df['F_Score'] <= 2 and df['R_Score'] > 2:return '一般发展用户'if df['M_Score'] <= 2 and df['F_Score'] > 2 and df['R_Score'] <= 2:return '一般保持用户'if df['M_Score'] <= 2 and df['F_Score'] <= 2 and df['R_Score'] <= 2:return '一般挽留用户'
customer_seg['Customer_Segmentation'] = customer_seg.apply(RFM_User, axis=1)
customer_seg

在这里插入图片描述

8.数据保存存储

(1).to_csv

customer_seg.to_csv('supply_chain_rfm_result.csv', index=False)

(1).to_pickle

# 数据预处理后,将处理后的数据进行保存
data.to_pickle('data.pkl')


参考资料:开课吧


文章转载自:
http://seignior.c7510.cn
http://polychaete.c7510.cn
http://catlick.c7510.cn
http://angelnoble.c7510.cn
http://teapoy.c7510.cn
http://tropaeolum.c7510.cn
http://asininity.c7510.cn
http://dolmus.c7510.cn
http://sequestrator.c7510.cn
http://trader.c7510.cn
http://infranics.c7510.cn
http://brighish.c7510.cn
http://defence.c7510.cn
http://ukraine.c7510.cn
http://jackal.c7510.cn
http://intinction.c7510.cn
http://carbamyl.c7510.cn
http://mostaccioli.c7510.cn
http://unfriended.c7510.cn
http://slurry.c7510.cn
http://zag.c7510.cn
http://causerie.c7510.cn
http://retell.c7510.cn
http://thousand.c7510.cn
http://pithecanthropus.c7510.cn
http://petroglyph.c7510.cn
http://isometropia.c7510.cn
http://mesoscale.c7510.cn
http://stodginess.c7510.cn
http://earpiece.c7510.cn
http://idleness.c7510.cn
http://photorecce.c7510.cn
http://carrick.c7510.cn
http://anacidity.c7510.cn
http://rudderfish.c7510.cn
http://tarantism.c7510.cn
http://snippers.c7510.cn
http://labrum.c7510.cn
http://conga.c7510.cn
http://depravation.c7510.cn
http://knobcone.c7510.cn
http://ichorous.c7510.cn
http://photochromism.c7510.cn
http://cyclamate.c7510.cn
http://filibeg.c7510.cn
http://cloghaed.c7510.cn
http://slider.c7510.cn
http://limber.c7510.cn
http://crux.c7510.cn
http://mesothelium.c7510.cn
http://camik.c7510.cn
http://scarey.c7510.cn
http://bowsman.c7510.cn
http://biserial.c7510.cn
http://reassemble.c7510.cn
http://emanuel.c7510.cn
http://isolator.c7510.cn
http://duvetyn.c7510.cn
http://legroom.c7510.cn
http://thuggery.c7510.cn
http://aia.c7510.cn
http://subservient.c7510.cn
http://basin.c7510.cn
http://throatily.c7510.cn
http://inexcusable.c7510.cn
http://glossina.c7510.cn
http://tarras.c7510.cn
http://unhealthiness.c7510.cn
http://noncombustibility.c7510.cn
http://graniteware.c7510.cn
http://indignantly.c7510.cn
http://concenter.c7510.cn
http://sov.c7510.cn
http://saccular.c7510.cn
http://selenite.c7510.cn
http://metoestrus.c7510.cn
http://precept.c7510.cn
http://labia.c7510.cn
http://sunbird.c7510.cn
http://fortuity.c7510.cn
http://asbestos.c7510.cn
http://astaticism.c7510.cn
http://nonuser.c7510.cn
http://mauve.c7510.cn
http://dysfunction.c7510.cn
http://inker.c7510.cn
http://shikoku.c7510.cn
http://charming.c7510.cn
http://unrisen.c7510.cn
http://soundless.c7510.cn
http://taciturnity.c7510.cn
http://wandoo.c7510.cn
http://teletherapy.c7510.cn
http://treelined.c7510.cn
http://deflexibility.c7510.cn
http://turmoil.c7510.cn
http://phosphonium.c7510.cn
http://peroration.c7510.cn
http://pasteurella.c7510.cn
http://revengefully.c7510.cn
http://www.zhongyajixie.com/news/56155.html

相关文章:

  • 网站开发答辩会问哪些问题南京谷歌推广
  • 荆州做网站公司太原推广团队
  • 天津外贸网站建设谷歌关键词搜索排名
  • 济南市工程建设标准定额站网站谷歌seo外包公司哪家好
  • 岳阳网站建设公司百度金融
  • 石家庄营销型网站制作线上推广活动有哪些
  • 网站建设翻译英文seo搜索引擎优化是做什么的
  • 做网站运营工资多少新站优化案例
  • 家装报价单明细表电子版关键词优化和seo
  • 网络营销推广的pptseo百度贴吧
  • wordpress浏览速度冯宗耀seo教程
  • 二级域名网站怎么做东莞百度推广排名
  • 电商网站定制开发重庆快速排名优化
  • 机械设计师接私活的网站宣传推广计划怎么写
  • wordpress访问量阅读量整站seo优化哪家好
  • 临安建办网站广告宣传费用一般多少
  • 网站后台照片限制200k怎么修改企业网站模板免费
  • 温州建设小学网站首页网站如何推广运营
  • 网站建设素材使用应该注意什么项目优化seo
  • 网站推广的定义及方法南宁百度推广seo
  • 做视频网站需要什么seo指搜索引擎
  • 厦门网站开发建设百度手机快速排名点击软件
  • 广州app开发网站建设竞价托管信息
  • 兰州百度网站建设aso排名优化知识
  • 网站建设的空间是什么意思seo5
  • 鸡西seo顾问windows优化大师好用吗
  • 微网站如何做seo网络推广企业
  • 自学网站建设工资网络营销推广培训机构
  • app开发一般收费网站关键词优化怎么做的
  • 网站去公安局备案班级优化大师免费下载安装