五月综合激情婷婷六月,日韩欧美国产一区不卡,他扒开我内裤强吻我下面视频 ,无套内射无矿码免费看黄,天天躁,日日躁,狠狠躁

新聞動態(tài)

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

發(fā)布日期:2022-03-13 18:59 | 文章來源:站長之家

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

1 數(shù)據(jù)預(yù)處理

1.1 股票歷史數(shù)據(jù)csv文件讀取

import pandas as pd
import csv
df = pd.read_csv("/home/kesci/input/maotai4154/maotai.csv")

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

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

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

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

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)



2 pyecharts實(shí)現(xiàn)數(shù)據(jù)可視化

2.1 導(dǎo)入庫

import pyecharts.options as opts
from pyecharts.charts import Line

2.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")

2.5 完整代碼展示

import pyecharts.options as opts
from 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é)果展示

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

香港服務(wù)器租用

版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開通

自選配置、實(shí)時(shí)開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部