PYTHON4FINANCE Telegram 1040
This media is not supported in your browser
VIEW IN TELEGRAM
رسم نمودارهای تعاملی با plotly
یکی از ماژول های عالی برای رسم نمودارهای تعاملی ماژول plotly است. با استفاده از این ماژول می توان نمودارهای متنوعی را به راحتی ترسیم کرد. مثلا می خواهید قیمت های روزانه یک سهم را در یک بازه طولانی در یک نمودار تعاملی نشان دهید.
ابتدا ماژولهای مورد نیاز را ایمپورت می کنیم:
import yfinance as yf
import plotly.express as px
import pandas as pd

در گام بعد اطلاعات سهم را برای یک بازه 3 ساله دریافت می‌کنیم:
msft = yf.Ticker("MSFT")
msft_hist = msft.history(period="3y")

حالا داده های روز و ماه و سال را دریافت می کنیم:
msft_hist['Date'] = msft_hist.index.date
msft_hist['Year'] = msft_hist.index.year
msft_hist['Month'] = msft_hist.index.month_name()
msft_hist['Day'] = msft_hist.index.day

حالا نوبت رسم داده هاست. با یک نمودار sunburst کار را تمام می کنیم:
fig = px.sunburst(msft_hist, path=['Year', 'Month', 'Day'], values='Close',
title='Microsoft Stock Closing Prices Sunburst Chart Over the Last Year' , height=700)
fig.show()



پایتون برای مالی
🆔 www.tgoop.com/python4finance
39



tgoop.com/python4finance/1040
Create:
Last Update:

رسم نمودارهای تعاملی با plotly
یکی از ماژول های عالی برای رسم نمودارهای تعاملی ماژول plotly است. با استفاده از این ماژول می توان نمودارهای متنوعی را به راحتی ترسیم کرد. مثلا می خواهید قیمت های روزانه یک سهم را در یک بازه طولانی در یک نمودار تعاملی نشان دهید.
ابتدا ماژولهای مورد نیاز را ایمپورت می کنیم:

import yfinance as yf
import plotly.express as px
import pandas as pd

در گام بعد اطلاعات سهم را برای یک بازه 3 ساله دریافت می‌کنیم:
msft = yf.Ticker("MSFT")
msft_hist = msft.history(period="3y")

حالا داده های روز و ماه و سال را دریافت می کنیم:
msft_hist['Date'] = msft_hist.index.date
msft_hist['Year'] = msft_hist.index.year
msft_hist['Month'] = msft_hist.index.month_name()
msft_hist['Day'] = msft_hist.index.day

حالا نوبت رسم داده هاست. با یک نمودار sunburst کار را تمام می کنیم:
fig = px.sunburst(msft_hist, path=['Year', 'Month', 'Day'], values='Close',
title='Microsoft Stock Closing Prices Sunburst Chart Over the Last Year' , height=700)
fig.show()



پایتون برای مالی
🆔 www.tgoop.com/python4finance

BY Python4Finance


Share with your friend now:
tgoop.com/python4finance/1040

View MORE
Open in Telegram


Telegram News

Date: |

A new window will come up. Enter your channel name and bio. (See the character limits above.) Click “Create.” On Tuesday, some local media outlets included Sing Tao Daily cited sources as saying the Hong Kong government was considering restricting access to Telegram. Privacy Commissioner for Personal Data Ada Chung told to the Legislative Council on Monday that government officials, police and lawmakers remain the targets of “doxxing” despite a privacy law amendment last year that criminalised the malicious disclosure of personal information. Users are more open to new information on workdays rather than weekends. 3How to create a Telegram channel? With Bitcoin down 30% in the past week, some crypto traders have taken to Telegram to “voice” their feelings.
from us


Telegram Python4Finance
FROM American