๐Ÿ˜Ž ๊ณต๋ถ€ํ•˜๋Š” ์ง•์ง•์•ŒํŒŒ์นด๋Š” ์ฒ˜์Œ์ด์ง€?

Dash์™€ Python์„ ์‚ฌ์šฉํ•˜์—ฌ ์‚ฌ์šฉ์ž ์ž…๋ ฅ ๊ธฐ๋ฐ˜ ๊ทธ๋ž˜ํ”„ ๋ณธ๋ฌธ

๐Ÿ‘ฉ‍๐Ÿ’ป ์ธ๊ณต์ง€๋Šฅ (ML & DL)/Serial Data

Dash์™€ Python์„ ์‚ฌ์šฉํ•˜์—ฌ ์‚ฌ์šฉ์ž ์ž…๋ ฅ ๊ธฐ๋ฐ˜ ๊ทธ๋ž˜ํ”„

์ง•์ง•์•ŒํŒŒ์นด 2022. 11. 14. 14:47
728x90
๋ฐ˜์‘ํ˜•

<๋ณธ ๋ธ”๋กœ๊ทธ๋Š” pythonprogramming_net ๋ธ”๋กœ๊ทธ๋ฅผ ์ฐธ๊ณ ํ•ด์„œ ๊ณต๋ถ€ํ•˜๋ฉฐ ์ž‘์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค>

https://pythonprogramming.net/dynamic-data-visualization-application-dash-python-tutorial/

 

Python Programming Tutorials

Dynamic Graph based on User Input - Data Visualization GUIs with Dash and Python p.3 Welcome to part three of the web-based data visualization with Dash tutorial series. Up to this point, we've learned how to make a simple graph and how to dynamically upda

pythonprogramming.net

 

 

 

๐ŸŽจ pandas์˜ datareader์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ค๊ธฐ

pip install --upgrade pandas pandas-datareader

 

๐ŸŽจ ์‚ฌ์šฉ์ž ์ž…๋ ฅ ๊ธฐ๋ฐ˜ ๋™์  ๊ทธ๋ž˜ํ”„

  • ๋ฐ์ดํ„ฐ ๋กœ๋“œ
import pandas_datareader.data as web
import datetime
import dash
import dash_core_components as dcc
import dash_html_components as html

# ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ค๋ ค๋Š” ์†Œ์Šค, ์‹œ์ž‘ ๋‚ ์งœ/์‹œ๊ฐ„, ์ข…๋ฃŒ ๋‚ ์งœ/์‹œ๊ฐ„์„ ์ง€์ •
# ๋ฐ˜ํ™˜์€ Pandas ๋ฐ์ดํ„ฐ ํ”„๋ ˆ์ž„
stock = 'TSLA'

start = datetime.datetime(2015, 1, 1, 0, 0)
end = datetime.datetime.now()
df = web.DataReader(stock, 'yahoo', start, end)
df.reset_index(inplace=True)
df.set_index("Date", inplace=True)

#print(df.info())

 

 

  • app.layout ๋‚ด๋ถ€์—์„œ ๋‹ค์Œ data๋ถ€๋ถ„์„ ์ˆ˜์ •
  • x์™€ y ๊ฐ’์„ ์›ํ•˜๋Š” ๊ฐ’์œผ๋กœ ๋ฐ”๊พธ๋Š” ๊ฒƒ
app = dash.Dash(__name__)
app.layout = html.Div(children=[
    html.H1(children='์ •์  ๊ทธ๋ž˜ํ”„!'),

    html.Div(children='''
        ํ…Œ์Šฌ๋ผ ์ฃผ์‹ ๊ทธ๋ž˜ํ”„๋ฅผ ๋งŒ๋“ค์–ด๋ณด์ž!!.
    '''),

    dcc.Graph(
        id='example-graph',
        figure={
            'data': [
                {'x': df.index, 'y': df.Close, 'type': 'line', 'name': stock},
            ],
            'layout': {
                'title': stock
            }
        }
    )
])

if __name__ == '__main__':
    app.run_server(host='0.0.0.0', port=8090 ,debug=True)

 

 

 

 

 

 

728x90
๋ฐ˜์‘ํ˜•
Comments