Spaces:
Runtime error
Runtime error
File size: 1,471 Bytes
fb03298 20ea3de fb03298 20ea3de d8dcaa0 20ea3de 7020053 20ea3de b207cbf 20ea3de 7f34bad 20ea3de 4a1c092 20ea3de fb03298 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
!pip install plotly==5.3.1
import streamlit as st
import pandas as pd
import plotly.express as px
@st.cache_data
def load_data():
"""Function for loading data"""
df = pd.read_csv("all_stocks_5yr.csv", index_col="date")
numeric_df = df.select_dtypes(['float','int'])
numeric_cols = numeric_df.columns
text_df = df.select_dtypes(['object'])
text_cols = text_df.columns
stock_column = df['Name']
unique_stocks = stock_column.unique()
return df, numeric_cols, text_cols, unique_stocks
df, numeric_cols, text_cols, unique_stocks = load_data()
# Title of dashboard
st.title("Stock Dashboard")
# add checknob to sidebar
check_box = st.sidebar.checkbox(label="Display dataset")
if check_box:
# lets show the dataset
st.write(df)
# give sidebar a title
st.sidebar.title("Settings")
st.sidebar.subheader("Timeseries settings")
feature_selection = st.sidebar.multiselect(label="Features to plot",
options=numeric_cols)
stock_dropdown = st.sidebar.selectbox(label="Stock Ticker",
options=unique_stocks)
print(feature_selection)
df = df[df['Name']==stock_dropdown]
df_features = df[feature_selection]
plotly_figure = px.line(data_frame=df_features,
x=df_features.index,y=feature_selection,
title=(str(stock_dropdown) + ' ' +'timeline')
)
st.plotly_chart(plotly_figure) |