My_first_app / app.py
madsryfeldt's picture
Create app.py
585d667 verified
raw
history blame
No virus
999 Bytes
import pandas as pd
import streamlit as st
# Read the CSV file into a Pandas DataFrame
df = pd.read_csv('cph_airbnb_listings.csv')
# Sort the DataFrame by 'neighbourhood' and then by 'price'
sorted_df = df.sort_values(by=['neighbourhood', 'price'])
# Create a Streamlit app
st.title('my_first_app')
# Allow user to select a specific neighbourhood
selected_neighbourhood = st.selectbox('Select Neighbourhood', sorted_df['neighbourhood'].unique())
# Filter the DataFrame based on selected neighbourhood
filtered_df = sorted_df[sorted_df['neighbourhood'] == selected_neighbourhood]
# Allow user to set a price range filter
price_range = st.slider('Select Price Range', min_value=0, max_value=10000, step=10, value=(0, 1000))
# Filter the DataFrame based on selected price range
filtered_df = filtered_df[(filtered_df['price'] >= price_range[0]) & (filtered_df['price'] <= price_range[1])]
# Display the filtered DataFrame
st.write('Below is the sorted and filtered data:')
st.write(filtered_df)