File size: 1,162 Bytes
1965883
2249a14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1965883
2249a14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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)