日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

.net bitmap rgb数据_Python商务与经济统计学-数据描述

發(fā)布時(shí)間:2025/3/12 python 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 .net bitmap rgb数据_Python商务与经济统计学-数据描述 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

案例2-1、3-1 Pelican 商店

本案例之中主要涉及到Pandas和pyecharts的一些功能,比如利用pandas進(jìn)行數(shù)據(jù)篩選,百分比頻數(shù)統(tǒng)計(jì),將數(shù)據(jù)進(jìn)行分組,分組統(tǒng)計(jì),相關(guān)性分析等。另外還涉及到了pyecharts的餅圖,直方圖,散點(diǎn)圖的繪制。

讀入數(shù)據(jù)

import pandas as pd import numpy as np data = pd.read_csv("PelicanStores.csv") data = data.iloc[:,:8]#過濾數(shù)據(jù)選擇前8列 data.head()#看一下前五行

問題1 主要變量的百分?jǐn)?shù)頻數(shù)分布

#Items(購買商品的總件數(shù))百分?jǐn)?shù)頻數(shù)分布 Items_percent_frequency_distribution = (pd.value_counts(data["Items"])/np.size(data["Items"]))*100 Items_percent_frequency_distribution

#Net Sales(凈銷售額)百分?jǐn)?shù)頻數(shù)分布 bins = [0, 50, 100, 150, 200, 250, 300] data["Net Sales Group"] = pd.cut(data["Net Sales"], bins, right=False)#對數(shù)據(jù)進(jìn)行分組 Net_Sales_percent_frequency_distribution = (pd.value_counts(data["Net Sales Group"])/np.size(data["Net Sales Group"]))*100 Net_Sales_percent_frequency_distribution

#Age(年齡)百分?jǐn)?shù)頻數(shù)分布 bins = [20, 30, 40, 50, 60, 70, 80] data["Age_Group"] = pd.cut(data["Age"], bins, right=False) Age_percent_frequency_distribution = (pd.value_counts(data["Age_Group"])/np.size(data["Age_Group"]))*100 Age_percent_frequency_distribution

問題2:條形圖或餅形圖,以顯示顧客使用各種付款方式的購物數(shù)量

#購物數(shù)量有兩個(gè)維度,購買商品的總件數(shù)和銷售額 M_P_Items_Net_Sales = data.groupby(by=["Method of Payment"])["Items","Net Sales"].agg({"Items":np.sum,"Net Sales":np.sum}) M_P_Items_Net_Sales = M_P_Items_Net_Sales.sort_values(by="Net Sales",ascending=False) M_P_Items_Net_Sales

#條形圖 from pyecharts import Bar, Grid x_line = [i for i in M_P_Items_Net_Sales.index.format()] y_line_Items = [i[0] for i in M_P_Items_Net_Sales.values] y_line_NS = [i[1] for i in M_P_Items_Net_Sales.values] bar1 = Bar("Items",title_text_size=26, title_top=10, title_pos=10, width=1000, height=400, background_color="rgb(255,255,255)") bar1.add("", x_line, y_line_Items ,xaxis_label_textsize=12,bar_category_gap='20%') bar2 = Bar("Net Sales",title_text_size=26, title_top=300, title_pos=10, width=1000, height=400, background_color="rgb(255,255,255)") bar2.add("", x_line, y_line_NS ,xaxis_label_textsize=12,bar_category_gap='20%') grid = Grid(height=600, width=1000) grid.add(bar1, grid_bottom="60%") grid.add(bar2, grid_top="60%") grid

#餅圖 from pyecharts import Pie pie1 = Pie("Items", title_text_size=26, title_top=10, title_pos=10) pie1.add("", x_line, y_line_Items, is_label_show=True, is_legend_show=False, label_text_size=10,center=[30,50], radius=[0,45]) pie2 = Pie("Net Sales", title_text_size=26, title_top=10, title_pos=500) pie2.add("", x_line, y_line_NS, is_label_show=True, is_legend_show=False, label_text_size=10,legend_orient='vertical',center=[70,50], radius=[0,45]) grid = Grid(height=600, width=1000) grid.add(pie1, grid_left="60%") grid.add(pie2, grid_right="60%") grid

問題3:顧客類型(普通或促銷)與凈銷售額的交叉分組表,對相似性與差異性進(jìn)行評價(jià)

data_CN_table = data.pivot_table(values=["Net Sales"], index=["Age_Group"], columns=["Type of Customer"], aggfunc=[np.sum], fill_value=0) data_CN_table

  • ①促銷所產(chǎn)生的凈銷售額在20至70歲這個(gè)區(qū)間是比普通顧客要多一些的,其中以50到60歲這個(gè)區(qū)間較為明顯。
  • ②40到50歲,50到60歲這兩個(gè)年齡區(qū)間的人促銷所產(chǎn)生的凈銷售額相近。
  • ③超過30歲的人,隨著年齡的增加,消費(fèi)能力是一直下降的。
  • ④50到70歲的人更傾向只在促銷的時(shí)候購買商品。

問題4 探索凈銷售額與顧客年齡關(guān)系的散點(diǎn)圖

from pyecharts import Scatter data_NS_Age = data[["Net Sales", "Age"]] x_line_age = [i[1] for i in data_NS_Age.values] y_line_NS = [i[0] for i in data_NS_Age.values] scatter = Scatter() scatter.add("", x_line_age, y_line_NS)

問題5 凈銷售額的描述統(tǒng)計(jì)量和顧客的各種不同分類的凈銷售額的描述統(tǒng)計(jì)量

data["Net Sales"].describe()#凈銷售額的描述統(tǒng)計(jì)量

data.groupby(["Type of Customer"])["Net Sales"].describe() #分組進(jìn)行統(tǒng)計(jì)描述

問題6 關(guān)于年齡與凈銷售額之間關(guān)系的描述統(tǒng)計(jì)量

#相關(guān)性分析 data_NS_Age.corr()

年齡與凈銷售額之間有一個(gè)負(fù)的相關(guān)關(guān)系,證明年齡越大可能所消費(fèi)的金額更小。

總結(jié)

以上是生活随笔為你收集整理的.net bitmap rgb数据_Python商务与经济统计学-数据描述的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。