Let's now proceed to using Pandas in a Streamlit app. Particularly, we're going to create an app that allows the loading of a CSV data upon clicking on a button.
Here's an explanation of the code in a step-by-step manner:
- Import necessary libraries
- Display the title of the app
- Create a conditional button that displays a Pandas DataFrame upon clicking on the
Load data
button
import streamlit as st
import pandas as pd
st.title('🐼 Pandas - A minimum working example')
if st.button('Load data'):
df = pd.read_csv('https://raw.githubusercontent.com/dataprofessor/data/master/delaney_solubility_with_descriptors.csv')
st.write(df)
else:
st.info('👆 Click on the button ')
The above code gives us the following Streamlit app (GitHub repo | Demo app)
Now that you have this Pandas app completed, can you build upon this Streamlit app by adding input widgets for taking in user provided URL to a CSV file that can be used for displaying the CSV file as a DataFrame.
📣 Learn in Public:
Share your solution (the updated Streamlit app) on social media (Twitter and/or LinkedIn) and tag us (
@streamlit
).