Streamlit app does not update

Hi there,

I created an app yesterday and it ran fine. This morning have been wanting to make changes to it (different text, position visuals elsewhere on page etc) and I can change it in the .py file but when I run the changes are not reflecting on the webpage. How do I fix this?

I have removed the cache (even though I’m not caching any data etc).

Thank you in advance.

import streamlit as st
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px
import plotly.graph_objects as go
import datetime as dt

Add Refresh Date

Today_Date = str(dt.datetime.now())

Title App

st.title(“Age vs Utilisation Matrix:”)

League and Season

st.markdown(‘2020/21 DSTV Premiership’)

App description

st.markdown(“This web application is divided into two parts\n.”
‘1) It visualises each teams squad breakdown by age. The higher the curve the more players in that age bracket/range.\n’
“2) The second visual breaks down each player’s playing during the 2020/21 DSTV Premiership season.\n”
‘Overtime minutes are not included.’)

Read data - Age Squad Data

Squad = pd.read_csv(r’C:\Users\Alex\Desktop\DSTV_Prem_Age_Squad_2021.csv’)

Ridgeplot

fig = px.violin(Squad, y=‘Team’, x=‘Age’,
orientation=‘h’).update_traces(side=‘positive’, width=2)

Figure size

fig.update_layout(
width=1000,
height=800
)

Visualise chart

st.plotly_chart(fig)

Sidebar - Team selection

sorted_unique_team = sorted(Squad.Team.unique())
selected_team = st.multiselect(‘Choose a Team’, sorted_unique_team)

Header in main page

st.header(‘Display Playing Time of Selected Team(s)’)

Filtering data

df_select_team = Squad[(Squad.Team.isin(selected_team))]

Show data via a tickbox

if st.checkbox(‘Show Data’):
df_select_team

Scatter plot

fig = px.scatter(df_select_team, x = ‘Age’, y = ‘Percent_Team_Mins_Played’,
text = ‘Last_Name’, color=‘Starting appearances’)

Figure text placement

fig.update_traces(textposition=‘top center’)

Figure size

fig.update_layout(
width=1000,
height=500
)

Visualise chart

st.plotly_chart(fig)

Refresh Date

st.markdown(f"This page was last updated on {Today_Date}")

`

Preformatted text

`

Hi, Could you share your code? Would be helpful to determine what’s causing the problem.

@maarten-betman attached above

1 Like

Hi @Mysteryink1992 , please put your code inside a code block. The makes it more readable, preserves that indentations, etc.

Please check these docs on how to achieve this in markdown.

@maarten-betman can’t get that working - documentation not clear enough for me how to do that. Would attach file but not possible so have decreased the size of title which actually just show the logic/step by step process.

Just curious as to why same code doesn’t update to yesterday’s code
?

Nevermind
just worked and updated the script
maybe some bug on the platform??

3 back ticks begins a code block and 3 back ticks under your code ends the code block. For correct syntax highlighting you can add “python” after the first 3 back ticks.

I don’t know what you exactly did. I doesn’t sound like behaviour I have ever seen in streamlit and I can’t replicate your reported error. Perhaps your browser cached something. Your can always press “R” when in the streamlit app to re-run your code.

1 Like

Thanks for that! Good to know and helpful for the next code problem.

1 Like

This is the proper way to post python source code in the forum in markdown syntax:

```python
Put your python code here
```
2 Likes