亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術(shù)文章
文章詳情頁

python實(shí)現(xiàn)股票歷史數(shù)據(jù)可視化分析案例

瀏覽:4日期:2022-06-17 09:07:59
目錄1 數(shù)據(jù)預(yù)處理1.1 股票歷史數(shù)據(jù)csv文件讀取1.2 關(guān)鍵數(shù)據(jù)——在csv文件中選擇性提取“列”1.3 數(shù)據(jù)類型轉(zhuǎn)換1.4 數(shù)據(jù)按列提取并累加性存入列表2 pyecharts實(shí)現(xiàn)數(shù)據(jù)可視化2.1 導(dǎo)入庫2.2 初始化畫布2.3 根據(jù)需要傳入關(guān)鍵性數(shù)據(jù)并畫圖2.4 將生成的文件形成HTML代碼并下載2.5 完整代碼展示3 結(jié)果展示

投資有風(fēng)險(xiǎn),選擇需謹(jǐn)慎。 股票交易數(shù)據(jù)分析可直觀股市走向,對于如何把握股票行情,快速解讀股票交易數(shù)據(jù)有不可替代的作用!

1 數(shù)據(jù)預(yù)處理1.1 股票歷史數(shù)據(jù)csv文件讀取

import pandas as pdimport csv

df = pd.read_csv('/home/kesci/input/maotai4154/maotai.csv')

python實(shí)現(xiàn)股票歷史數(shù)據(jù)可視化分析案例

1.2 關(guān)鍵數(shù)據(jù)——在csv文件中選擇性提取“列”

df_high_low = df[[’date’,’high’,’low’]]

python實(shí)現(xiàn)股票歷史數(shù)據(jù)可視化分析案例

1.3 數(shù)據(jù)類型轉(zhuǎn)換

df_high_low_array = np.array(df_high_low)df_high_low_list =df_high_low_array.tolist()

python實(shí)現(xiàn)股票歷史數(shù)據(jù)可視化分析案例

1.4 數(shù)據(jù)按列提取并累加性存入列表

price_dates, heigh_prices, low_prices = [], [], []for content in zip(df_high_low_list): price_date = content[0][0] heigh_price = content[0][1] low_price = content[0][2] price_dates.append(price_date) heigh_prices.append(heigh_price) low_prices.append(low_price)

python實(shí)現(xiàn)股票歷史數(shù)據(jù)可視化分析案例

python實(shí)現(xiàn)股票歷史數(shù)據(jù)可視化分析案例

python實(shí)現(xiàn)股票歷史數(shù)據(jù)可視化分析案例

2 pyecharts實(shí)現(xiàn)數(shù)據(jù)可視化2.1 導(dǎo)入庫

import pyecharts.options as optsfrom pyecharts.charts import Line2.2 初始化畫布

Line(init_opts=opts.InitOpts(width='1200px', height='600px'))2.3 根據(jù)需要傳入關(guān)鍵性數(shù)據(jù)并畫圖

.add_yaxis(series_name='最低價(jià)',y_axis=low_prices,markpoint_opts=opts.MarkPointOpts( data=[opts.MarkPointItem(value=-2, name='周最低', x=1, y=-1.5)]),markline_opts=opts.MarkLineOpts( data=[opts.MarkLineItem(type_='average', name='平均值'),opts.MarkLineItem(symbol='none', x='90%', y='max'),opts.MarkLineItem(symbol='circle', type_='max', name='最高點(diǎn)'), ]), )

tooltip_opts=opts.TooltipOpts(trigger='axis'),toolbox_opts=opts.ToolboxOpts(is_show=True),xaxis_opts=opts.AxisOpts(type_='category', boundary_gap=True)2.4 將生成的文件形成HTML代碼并下載

.render('HTML名字填這里.html')

python實(shí)現(xiàn)股票歷史數(shù)據(jù)可視化分析案例

2.5 完整代碼展示

import pyecharts.options as optsfrom pyecharts.charts import Line ( Line(init_opts=opts.InitOpts(width='1200px', height='600px')) .add_xaxis(xaxis_data=price_dates) .add_yaxis(series_name='最高價(jià)',y_axis=heigh_prices,markpoint_opts=opts.MarkPointOpts( data=[opts.MarkPointItem(type_='max', name='最大值'),opts.MarkPointItem(type_='min', name='最小值'), ]),markline_opts=opts.MarkLineOpts( data=[opts.MarkLineItem(type_='average', name='平均值')]), ) .add_yaxis(series_name='最低價(jià)',y_axis=low_prices,markpoint_opts=opts.MarkPointOpts( data=[opts.MarkPointItem(value=-2, name='周最低', x=1, y=-1.5)]),markline_opts=opts.MarkLineOpts( data=[opts.MarkLineItem(type_='average', name='平均值'),opts.MarkLineItem(symbol='none', x='90%', y='max'),opts.MarkLineItem(symbol='circle', type_='max', name='最高點(diǎn)'), ]), ) .set_global_opts(title_opts=opts.TitleOpts(title='茅臺股票歷史數(shù)據(jù)可視化', subtitle='日期、最高價(jià)、最低價(jià)可視化'),tooltip_opts=opts.TooltipOpts(trigger='axis'),toolbox_opts=opts.ToolboxOpts(is_show=True),xaxis_opts=opts.AxisOpts(type_='category', boundary_gap=True), ) .render('everyDayPrice_change_line_chart2.html'))3 結(jié)果展示

python實(shí)現(xiàn)股票歷史數(shù)據(jù)可視化分析案例

python實(shí)現(xiàn)股票歷史數(shù)據(jù)可視化分析案例

python實(shí)現(xiàn)股票歷史數(shù)據(jù)可視化分析案例

到此這篇關(guān)于python實(shí)現(xiàn)股票歷史數(shù)據(jù)可視化分析案例的文章就介紹到這了,更多相關(guān)python股票數(shù)據(jù)可視化內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 一级特黄高清完整大片 | 亚洲精品不卡视频 | 精品视频在线观看 | 国产v片免费播放 | 91日本在线精品高清观看 | 国产在线不卡午夜精品2021 | 国产高清乱码无卡女大生 | 1024人成网色www | 欧美另类亚洲一区二区 | 久久成人在线 | 亚洲国产一区二区三区四区 | 日本免费人成黄页网观看视频 | 99精品国产成人一区二区在线 | 欧美一级爱操视频 | 欧美国产一区二区二区 | 色婷婷婷婷 | 中文字幕无线码欧美成人 | 国产欧美一区二区三区在线看 | 国产线视频精品免费观看视频 | 国产精品免费视频网站 | 一区二区三区四 | 在线高清视频18jin观看 | 亚洲高清国产一线久久 | 午夜久久久久久亚洲国产精品 | 欧美黄色高清视频 | 91播放在线 | 欧美午夜激情影院 | 国产精品天仙tv在线观看 | 中文第一页 | 免费播放欧美一级特黄 | 在线观看网址入口2020国产 | 久久草在线视频播放 | 亚洲另类在线观看 | 91av麻豆| 亚洲精品456人成在线 | 亚洲美女一级片 | 欧美一级做一a做片性视频 欧美一级做一级爱a做片性 | 国产偷窥自拍视频 | 国产精品网站在线进入 | a级国产乱理片在线观看 | 国产欧美日韩不卡 |