-
Notifications
You must be signed in to change notification settings - Fork 0
/
NY_airbnb.py
58 lines (38 loc) · 1.57 KB
/
NY_airbnb.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import streamlit as st
import plotly.express as px
import pandas as pd
import numpy as np
import streamlit as st
import data
data = data.load_data()
def write():
st.sidebar.title("Search Filter")
selection = st.sidebar.slider("Select the Range of Price", 0,500,(0,100))
neighbourhood = st.sidebar.selectbox("Select the Boroughs",("Manhattan", "Brooklyn", "Queens", "Bronx", "Staten Island") )
room_type = st.sidebar.selectbox("Select Types of Rooms",("Entire home/apt", "Private room", "Shared room") )
data_lager_p = data[data['price'] > int(selection[0])]
data_low_p = data_lager_p[data_lager_p['price'] < int(selection[1])]
data_neighbour = data_low_p[data_low_p['neighbourhood_group'] == neighbourhood]
data_room = data_neighbour[data_neighbour['room_type'] == room_type]
final_data = data_room
#The hover_data argument accepts a list of column names to be added to the hover tooltip.
# The hover_name property controls which column is displayed in bold as the tooltip title
fig = px.scatter_mapbox(
final_data,
hover_data=['price', 'room_type'],
hover_name= "name",
color = 'neighbourhood',
lon = 'longitude',
lat = 'latitude',
size = 'price',
size_max=10,
opacity=.70,
zoom=10,
)
fig.layout.mapbox.style = 'stamen-terrain'
fig.update_layout()
st.plotly_chart(fig,width = 800,height = 800)