Spaces:
Runtime error
Runtime error
madsryfeldt
commited on
Commit
•
f98391b
1
Parent(s):
af2f8f0
Update app.py
Browse files
app.py
CHANGED
@@ -27,3 +27,20 @@ filtered_df = filtered_df[(filtered_df['price'] >= price_range[0]) & (filtered_d
|
|
27 |
# Display the filtered DataFrame
|
28 |
st.write('Below is the sorted and filtered data:')
|
29 |
st.write(filtered_df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
# Display the filtered DataFrame
|
28 |
st.write('Below is the sorted and filtered data:')
|
29 |
st.write(filtered_df)
|
30 |
+
|
31 |
+
# Calculate the average price of each available room in each selected neighbourhood
|
32 |
+
avg_prices = filtered_df.groupby(['neighbourhood', 'room_type'])['price'].mean().reset_index()
|
33 |
+
|
34 |
+
# Plot a histogram of the average prices
|
35 |
+
if not avg_prices.empty:
|
36 |
+
st.write('Histogram of Average Price of Each Available Room in Each Neighbourhood:')
|
37 |
+
fig, ax = plt.subplots()
|
38 |
+
for room_type in avg_prices['room_type'].unique():
|
39 |
+
room_prices = avg_prices[avg_prices['room_type'] == room_type]
|
40 |
+
ax.hist(room_prices['price'], bins=20, alpha=0.5, label=room_type)
|
41 |
+
ax.legend()
|
42 |
+
ax.set_xlabel('Average Price')
|
43 |
+
ax.set_ylabel('Frequency')
|
44 |
+
st.pyplot(fig)
|
45 |
+
else:
|
46 |
+
st.write('No data available for selected filters.')
|