hf_streamlit_loadfile2 / src /streamlit_app.py
louiecerv's picture
syncdsavesve
b7c4109
import streamlit as st
import pandas as pd
import altair as alt
import seaborn as sns
st.title("Palmer's Penguins")
st.markdown('Use this Streamlit app to make your own scatterplot about penguins!')
selected_x_var = st.selectbox('What do you want the x variable to be?',
['bill_length_mm', 'bill_depth_mm', 'flipper_length_mm', 'body_mass_g'])
selected_y_var = st.selectbox('What about the y?',
['bill_depth_mm', 'bill_length_mm', 'flipper_length_mm', 'body_mass_g'])
penguin_file = st.file_uploader('Select Your Local Penguins CSV')
if penguin_file is None:
st.info("Please upload a Penguins CSV file to begin.")
st.stop()
try:
penguins_df = pd.read_csv(penguin_file)
penguins_df = penguins_df.dropna()
st.success("Dataset loaded successfully!")
except Exception as e:
st.error(f"Error loading file: {e}")
st.stop()
sns.set_style('darkgrid')
markers = {"Adelie": "X", "Gentoo": "s", "Chinstrap":'o'}
alt_chart = (
alt.Chart(penguins_df, title="Scatterplot of Palmer's Penguins")
.mark_circle().encode(
x=selected_x_var,
y=selected_y_var,
color="species",
)
.interactive()
)
st.altair_chart(alt_chart, use_container_width=True)