Sitemap
pritesh

pritesh

Member-only story

Streamlit Use

13 min readApr 21, 2025

--

Hello,

Press enter or click to view image in full size
Photo by Scott Graham on Unsplash

Step 1: Install Streamlit

Before getting started, ensure you have Streamlit installed. You can install it using pip:

pip install streamlit

Step 2: Create a Streamlit Application

Here’s a basic example of a Streamlit app that displays a title, a sidebar for user input, a chart, and a data table.

import streamlit as st
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Set the title of the app
st.title('My First Streamlit App')
# Add a sidebar
st.sidebar.header('User Input')
# Add a slider for user input in the sidebar
user_input = st.sidebar.slider('Select a number:', min_value=1, max_value=100, value=50)
# Generate a random dataframe
df = pd.DataFrame({
'x': np.random.randn(100),
'y': np.random.randn(100)
})
# Display the dataframe as a table
st.write("### Random Data Table")
st.dataframe(df)
# Display a line chart
st.write("### Line Chart")
st.line_chart(df)
# Create and display a simple plot
fig, ax = plt.subplots()
ax.hist(df['x'], bins=20)
st.pyplot(fig)
# Show the user input value
st.write(f"### You…

--

--