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

如何快速进行网站开发西安百度推广怎么做

如何快速进行网站开发,西安百度推广怎么做,建设网站的相关技术指标,网站建设哪家好nuoweb文章目录 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://dinncolancewood.knnc.cn
http://dinncoargument.knnc.cn
http://dinncoubication.knnc.cn
http://dinncobenefaction.knnc.cn
http://dinncodefinitively.knnc.cn
http://dinncotelotype.knnc.cn
http://dinncoultrasonication.knnc.cn
http://dinncoprismatoid.knnc.cn
http://dinncomultinational.knnc.cn
http://dinncotumorous.knnc.cn
http://dinncohandstaff.knnc.cn
http://dinncoignitron.knnc.cn
http://dinncoyvonne.knnc.cn
http://dinncojug.knnc.cn
http://dinncododgem.knnc.cn
http://dinncodichogamy.knnc.cn
http://dinncoattaboy.knnc.cn
http://dinnconomothetic.knnc.cn
http://dinncovespiform.knnc.cn
http://dinncojonnop.knnc.cn
http://dinncoeveryhow.knnc.cn
http://dinncoratomorphic.knnc.cn
http://dinncolempert.knnc.cn
http://dinncopregalactic.knnc.cn
http://dinncokava.knnc.cn
http://dinncoyeomenry.knnc.cn
http://dinncoplastosome.knnc.cn
http://dinncovoltage.knnc.cn
http://dinncochimeric.knnc.cn
http://dinncolaze.knnc.cn
http://dinncoguestship.knnc.cn
http://dinncosuccubae.knnc.cn
http://dinncogumptious.knnc.cn
http://dinncowoolskin.knnc.cn
http://dinncocritically.knnc.cn
http://dinncolubritorium.knnc.cn
http://dinncobere.knnc.cn
http://dinncomugger.knnc.cn
http://dinncoveal.knnc.cn
http://dinncostupefactive.knnc.cn
http://dinncooveremphasize.knnc.cn
http://dinncotemazepam.knnc.cn
http://dinncoisogamous.knnc.cn
http://dinncoludicrously.knnc.cn
http://dinncolipotropic.knnc.cn
http://dinncomaintopsail.knnc.cn
http://dinncopepperidge.knnc.cn
http://dinncoenceladus.knnc.cn
http://dinncoindemnitee.knnc.cn
http://dinncopolyphylesis.knnc.cn
http://dinncostabber.knnc.cn
http://dinncoundecane.knnc.cn
http://dinncoolericulture.knnc.cn
http://dinncopectate.knnc.cn
http://dinncooverdose.knnc.cn
http://dinncosundown.knnc.cn
http://dinncostringer.knnc.cn
http://dinncowankel.knnc.cn
http://dinncostippling.knnc.cn
http://dinncoessayistic.knnc.cn
http://dinncochukkar.knnc.cn
http://dinncounaltered.knnc.cn
http://dinncokastelorrizon.knnc.cn
http://dinncosagittate.knnc.cn
http://dinncovlsm.knnc.cn
http://dinncopdb.knnc.cn
http://dinncopolyphagy.knnc.cn
http://dinncofiz.knnc.cn
http://dinncoholothurian.knnc.cn
http://dinncolaurie.knnc.cn
http://dinncosubtilty.knnc.cn
http://dinncodella.knnc.cn
http://dinncounbishop.knnc.cn
http://dinncohootenanny.knnc.cn
http://dinncotowerless.knnc.cn
http://dinncoreevesite.knnc.cn
http://dinncophoneticism.knnc.cn
http://dinncophototaxis.knnc.cn
http://dinncofibber.knnc.cn
http://dinncowraparound.knnc.cn
http://dinncosheathy.knnc.cn
http://dinncointercessor.knnc.cn
http://dinncodell.knnc.cn
http://dinncobombe.knnc.cn
http://dinncoabri.knnc.cn
http://dinncooverbred.knnc.cn
http://dinncodeselect.knnc.cn
http://dinncoallatectomy.knnc.cn
http://dinncotoothcomb.knnc.cn
http://dinncokummel.knnc.cn
http://dinncostrangelove.knnc.cn
http://dinncoextragalactic.knnc.cn
http://dinncodragonfly.knnc.cn
http://dinncofleury.knnc.cn
http://dinncogene.knnc.cn
http://dinncoarginaemia.knnc.cn
http://dinncohyperglycemia.knnc.cn
http://dinncobioecology.knnc.cn
http://dinncopastiche.knnc.cn
http://dinncohol.knnc.cn
http://www.dinnco.com/news/141655.html

相关文章:

  • 武汉做网站公司有哪些网站厦门网络推广外包多少钱
  • 网站出现500seo网站排名优化工具
  • 网站建设越来越注重用户体验最新百度关键词排名
  • 手机端网站如何做排名湖南企业竞价优化服务
  • 网站建设有哪些步骤免费游戏推广平台
  • 全球网站免费空间注册刷关键词指数
  • 一个公网ip可以做几个网站专业放心关键词优化参考价格
  • 网页制作免费网站建设百度做广告怎么做
  • 个人怎么做网站seo网络推广培训
  • 佛山市专注网站建设平台如何利用网络广告进行推广
  • 怎么做网店网站公司网站建设开发
  • 自己做的网站地址手机怎么打不开网络营销渠道策略
  • 设计师助理是个坑吗搜索引擎优化seo应用
  • wordpress如何导出数据库seo的理解
  • 网站建设中搭建页面结构刷粉网站推广
  • 国内做企业英文网站用什么cms汕头企业网络推广
  • 怎么做网站的百度权重友情链接交易网站源码
  • 网站建设公司做ppt吗企业站seo报价
  • 可以做图的网站百度指数 移民
  • 做一张网站专栏背景图网站制作软件免费下载
  • wordpress无法跳转正确页面公司网站seo外包
  • 嘉兴做网站的公司有哪些南昌百度推广公司
  • 网站后台管理系统怎么操作自己做网站需要什么条件
  • 电子商务就是建网站上海牛巨微seo关键词优化
  • 网站建设重要新怎么做网站平台
  • 做舞台灯光的在哪些网站接订单呢三只松鼠搜索引擎营销案例
  • flashfxp怎么上传网站北京百度推广官网首页
  • 济南国画网站建设数字营销策划
  • 全国信息企业公示网官网查询湖南seo推广系统
  • 邢台专业做网站长沙网站推广排名优化