I am using the same python code with streamlit v1.11 and v1.12.
But my dashboard seem to malfunction when using version1.12.
Please help!!
import plotly.express as px # pip install plotly-express
import streamlit as st # pip install streamlit
import pandas as pd
import codecs
import csv
counter = 0
def interactive_plot(a, b):
global counter
col1, col2 = st.columns(2)
x_axis_val = col1.selectbox('Select the X-axis', options=df.columns, key=counter)
y_axis_val = col2.selectbox('Select the Y-axis', options=df.columns, key=counter)
plot = px.scatter(df[a:b], x=x_axis_val, y=y_axis_val)
st.plotly_chart(plot, use_container_width=True)
counter += 1
def interactive_sheet(a, b):
parameterSelected = st.multiselect('Choose your parameters', df.columns)
#parameterSelected.append['Timestamp']
#nonRequired = [x for x in df if x not in parameterSelected]
csvDisplayed = df
st.dataframe(csvDisplayed[a:b])
st.set_page_config(page_title="XXX Dashboard", page_icon=":bar_chart:", layout="wide")
st.title(":bar_chart: XXX Dashboard")
st.markdown("##")
st.sidebar.header("Please upload a file:")
upload_file = st.sidebar.file_uploader('Select an XXX diagnostic file')
if upload_file is not None and 'data' not in st.session_state:
st.session_state.data = None
if upload_file is not None and st.session_state.data is None:
# Pandas data cleaning & formatting
csv_reader = csv.reader(codecs.iterdecode(upload_file, 'utf-8'))
st.session_state.data = df
if dashboard == 'Custom':
if upload_file is not None:
try:
df = st.session_state.data
col1, col2 = st.columns(2)
initialTime = col1.selectbox('Select the initial time', options=df['Timestamp'], key=counter)
finalTime = col2.selectbox('Select the final time',
options=df['Timestamp'][df[df['Timestamp'] == initialTime].index.values[0]:-1],
key=counter)
# Update the CSV
interactive_sheet(df[df['Timestamp'] == initialTime].index.values[0], df[df['Timestamp'] == finalTime].index.values[0])
# Data Visualization
interactive_plot(df[df['Timestamp'] == initialTime].index.values[0], df[df['Timestamp'] == finalTime].index.values[0])
counter = counter +1
except:
pass
elif dashboard == 'None':
st.header("Select a mode to continue")
This is what it look like when using version 1.11
This is using version 1.12