Context
Trying to build a timeseries chart using plotly using multiselect. This is what it looks like now:
Is there any reason I am getting this error? The code is listed below:
# Get the Data
# Streamlit knows not to always reload data unless its new data.
@st.cache
# import data from csv
def load_data():
#Get data
Gov_df = pd.read_csv('Timeseries/Trends on headline indicators.csv',index_col='Date',parse_dates=True)
# Want to get the numeric data
numeric_data = Gov_df.select_dtypes(include=[np.float64,np.int64])
# Want the columns attribute
numeric_cols = numeric_data.columns
# Get the text dataframe
text_data = Gov_df.select_dtypes(include='object')
text_cols = text_data.columns
return Gov_df, numeric_cols, text_cols
Gov_df, numeric_cols, text_cols = load_data()
#Time series analysis
st.subheader("Time Series Analysis")
checkbox1 = st.checkbox("Display Chart")`
if checkbox1:
# Can select what columns to look at
Columns_select1 = st.multiselect(label="Select Columns",
options=numeric_cols)
# Only show dataframe with these columns
dataframe_cols1 = Gov_df[Columns_select1]`
plotly_fig = px.line(data_frame=dataframe_cols1,x=dataframe_cols1.index,y=Columns_select1 )
st.plotly_chart(plotly_fig)
Thanks