콘텐츠로 이동

그래프로 표시하기

실습 데이터

kospi

필요한 모듈 설치하기

!pip install gradio

google drive 연결하기

from google.colab import drive
drive.mount('/content/drive')

Gradio에서 그래프 그리기

import gradio as gr

df = pd.read_csv('/content/drive/MyDrive/Colab Notebooks/kospi.csv', sep=',', encoding="cp949")

c = ['Date', 'Close', 'Volume']
df = df[c]
df.rename(columns = {'Date':'날짜', 'Close':'종가', 'Volume':'거래량'}, inplace=True)

# 소수점 2자리로 반올림
df = df.round(2)

with gr.Blocks() as demo:
    with gr.Row():
        gr.Label(f"{df['종가'].min()}", label="최저점 지수")
        gr.Label(f"{df['종가'].max()}", label="최고점 지수")
    gr.DataFrame(df)
    gr.LinePlot(df, x="날짜", y="종가")

demo.launch()