中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

招聘網(wǎng)站做銷售2024很有可能再次封城嗎

招聘網(wǎng)站做銷售,2024很有可能再次封城嗎,簡述網(wǎng)站推廣方式,手機wap網(wǎng)站用什么語言開發(fā)四、使用PyEcharts數(shù)據(jù)分析案例(面向?qū)ο蟀?amp;#xff09; 【前言:為了鞏固之前的Python基礎(chǔ)知識(一)到(五),并為后續(xù)使用Python作為數(shù)據(jù)處理的好幫手,我們一起來用面向?qū)ο蟮乃枷雭砝怼?article class="baidu_pl">

四、使用PyEcharts數(shù)據(jù)分析案例(面向?qū)ο蟀?#xff09;

【前言:為了鞏固之前的Python基礎(chǔ)知識(一)到(五),并為后續(xù)使用Python作為數(shù)據(jù)處理的好幫手,我們一起來用面向?qū)ο蟮乃枷雭砝斫獯a】

1.文件讀取與數(shù)據(jù)處理(面向?qū)ο蟀?#xff09;
# main.py
"""
文本數(shù)據(jù)格式如下:
訂單編號,下單日期,下單金額,下單賬戶
json數(shù)據(jù)格式如下:
{id:編號,data:日期,money:金額,account:賬戶}
"""
import json
# 設(shè)計一個類完成數(shù)據(jù)封裝
class data_record:def __init__(self, id, data, money, account):self.id = id            # 訂單編號self.data = data        # 下單日期self.money = money      # 下單金額self.account = account  # 下單賬戶"""當類對象需要被轉(zhuǎn)換為字符串之前,會輸出內(nèi)存地址需要使用魔術(shù)方法__str__控制類轉(zhuǎn)換為字符串的行為詳情請看到最后"""def __str__(self):return f"{self.id}, {self.data}, {self.money}, {self.account}"# 設(shè)計一個抽象類定義文件讀取相關(guān)功能
class file_reader:# 讀取文件數(shù)據(jù),將讀到的每條數(shù)據(jù)轉(zhuǎn)換成list,返回data_record類def read_data(self) -> list[data_record]:pass# 讀取文本數(shù)據(jù)子類
class txt_file_reader(file_reader):# 使用構(gòu)造方法定義文件路徑def __init__(self, path):self.path = path# 復(fù)寫抽象方法def read_data(self) -> list[data_record]:f = open(self.path, 'r', encoding="UTF-8")data_record_list: list[data_record] = []for line in f.readlines():# 注意此處去除讀取到的line中的換行符line = line.strip()# 注意split方法得到一個列表,要將字符串表示的money轉(zhuǎn)換成intdata_list = line.split(",")data = data_record(data_list[0], data_list[1], int(data_list[2]), data_list[3])data_record_list.append(data)f.close()return data_record_list# 讀取json類型數(shù)據(jù)子類
class json_file_reader(file_reader):# 使用構(gòu)造方法定義文件路徑def __init__(self, path):self.path = path# 復(fù)寫抽象方法def read_data(self) -> list[data_record]:f = open(self.path, 'r', encoding="UTF-8")data_record_list: list[data_record] = []for line in f.readlines():# 將讀取到的每一行json類型轉(zhuǎn)換成python數(shù)據(jù)類型——字典類型data_dict = json.loads(line)data = data_record(data_dict["id"],data_dict["data"],int(data_dict["money"]),data_dict["account"])data_record_list.append(data)f.close()return data_record_listtxt_file = txt_file_reader("D:/txt_file.txt")
json_file = json_file_reader("D:/json_file.txt")
txt_list: list[data_record] = txt_file.read_data()
json_list: list[data_record] = json_file.read_data()"""
運行:
for line in txt_list:print(line)for line in json_list:print(line)
當類對象需要被轉(zhuǎn)換為字符串之前,會輸出內(nèi)存地址
故此時僅打印數(shù)據(jù)的地址
需要使用魔術(shù)方法__str__控制類轉(zhuǎn)換為字符串的行為
"""# 將兩個列表數(shù)據(jù)內(nèi)容合并
all_list: list[data_record] = txt_list + json_list
# 將同一天的銷售金額累加,使用字典存儲
data_dict = {}
for record in all_list:# 當前日期已經(jīng)存在,直接累加money即可if record.data in data_dict.keys():data_dict[record.data] += record.money# 當前日期不存在,需要添加該日期且將money存入else:data_dict[record.data] = record.moneyprint(data_dict)"""
輸出結(jié)果:
{'07-01': 5081, '07-02': 5360, '07-03': 2096, '07-04': 5174, '07-05': 5344, '07-06': 3162, '07-07': 2141, '07-08': 1701, '07-09': 3180}"""
2.可視化開發(fā)
# 在main.py中導(dǎo)入包
from pyecharts.charts import Bar
from pyecharts.options import *
from pyecharts.globals import ThemeType# 在1.文件讀取與數(shù)據(jù)處理(面向?qū)ο蟀?#xff09;代碼基礎(chǔ)上添加:# 得到柱狀圖類對象
bar = Bar(init_opts=InitOpts(theme=ThemeType.LIGHT))
# 將字典中所有日期作為x軸參數(shù),所有金額作為y軸參數(shù)
bar.add_xaxis(list(data_dict.keys()))
bar.add_yaxis("總金額", list(data_dict.values()), label_opts=LabelOpts(is_show=False))bar.set_global_opts(title_opts=TitleOpts(title="每日銷售總金額")
)bar.render("每日銷售總金額柱狀圖.html")

最終效果:

每日銷售總金額

記錄學習過程的筆記,歡迎大家一起討論,會持續(xù)更新

http://www.risenshineclean.com/news/2626.html

相關(guān)文章:

  • 網(wǎng)頁設(shè)計個人簡歷長春網(wǎng)站建設(shè)方案優(yōu)化
  • 祝賀網(wǎng)站上線百度貼吧人工客服
  • 福州免費建站品牌企業(yè)滄州seo公司
  • wordpress加速樂沈陽網(wǎng)絡(luò)seo公司
  • 最新淮北論壇windows優(yōu)化大師使用方法
  • 張家界做網(wǎng)站商品推廣軟文范例300字
  • 網(wǎng)站如何做支付寶接口seo 工具推薦
  • 移動端網(wǎng)站模板怎么做友情鏈接交換的作用在于
  • 近期國內(nèi)新聞熱點事件高級seo
  • 濰坊網(wǎng)絡(luò)營銷外包灰色行業(yè)關(guān)鍵詞優(yōu)化
  • 網(wǎng)站該怎么找到軟文代寫價格
  • WordPress添加live2dseo優(yōu)化包括哪些
  • 做網(wǎng)站有年費嗎作品提示優(yōu)化要刪嗎
  • 上海做網(wǎng)站優(yōu)化哪家好關(guān)鍵詞工具有哪些
  • 東莞做網(wǎng)站樂云seo今天晚上19點新聞聯(lián)播直播回放
  • 政務(wù)門戶網(wǎng)站建設(shè)方案怎么設(shè)計網(wǎng)站
  • 做網(wǎng)站賣東西seo優(yōu)化培訓(xùn)公司
  • 做一個大型網(wǎng)站aso搜索排名優(yōu)化
  • 在靜安正規(guī)的設(shè)計公司網(wǎng)站使用軟件提高百度推廣排名
  • 高端網(wǎng)站建設(shè)蘇州廣東seo推廣
  • 中國十大權(quán)威新聞媒體谷歌優(yōu)化教程
  • 南京網(wǎng)頁網(wǎng)站制作網(wǎng)站推廣的意義和方法
  • 蘋果網(wǎng)站用flash做百度西安分公司地址
  • 企業(yè)做網(wǎng)站有用嗎天涯今日足球賽事數(shù)據(jù)
  • 做網(wǎng)站單線程CPU和多線程cpu浙江網(wǎng)站建設(shè)推廣
  • 桂林建設(shè)網(wǎng)站公司營銷推廣有哪些形式
  • 高質(zhì)量的網(wǎng)站建設(shè)莆田百度快照優(yōu)化
  • 做編程的網(wǎng)站有哪些搜索引擎推廣一般包括哪些
  • ps網(wǎng)站導(dǎo)航怎么做餐飲營銷策劃方案
  • 怎么用大淘客做網(wǎng)站創(chuàng)建網(wǎng)頁步驟