Borya-Goldarb commited on
Commit
bd402d2
·
verified ·
1 Parent(s): 39d8496

Update pages/market_rent_estimation.py

Browse files
Files changed (1) hide show
  1. pages/market_rent_estimation.py +61 -54
pages/market_rent_estimation.py CHANGED
@@ -38,59 +38,6 @@ def main():
38
  sorted_indexes = df_properties_filtered.index[sorted_indices]
39
  reordered_df_properties_filtered = df_properties_filtered.loc[sorted_indexes]
40
 
41
- with tab2:
42
- st.title('Combined estimation')
43
- if 'user_select_value' not in st.session_state:
44
- st.session_state['user_select_value'] = ""
45
- if 'year_buit' not in st.session_state:
46
- st.session_state['year_buit'] = ""
47
- if 'submarket_val' not in st.session_state:
48
- st.session_state['submarket_val'] = ""
49
- if 'market_val' not in st.session_state:
50
- st.session_state['market_val'] = ""
51
-
52
- box_contents = [
53
- {"header": "Address", "content": st.session_state['user_select_value']},
54
- {"header": "LSF", "content": str(st.session_state['property_lsf'])},
55
- {"header": "Sub-Market", "content": st.session_state['submarket_val']},
56
- {"header": "Market", "content": st.session_state['market_val']}
57
- ]
58
-
59
- # Divide the layout into four columns
60
- col1, col2, col3, col4 = st.columns(4)
61
-
62
- for i, col in enumerate([col1, col2, col3, col4]):
63
- col.markdown(f"""
64
- <div style="padding: 20px; margin: 10px; text-align: center;">
65
- <h3 style="font-size: small;">{box_contents[i]['header']}</h3>
66
- <p style="font-size: small;">{box_contents[i]['content']}</p>
67
- </div>
68
- """, unsafe_allow_html=True)
69
-
70
- # Add padding between the boxes and the slider
71
- st.markdown('<style>div[data-testid="stBlock"]{margin-top: 20px;}</style>', unsafe_allow_html=True)
72
-
73
- def safe_eval(val):
74
- try:
75
- return ast.literal_eval(val)
76
- except (ValueError, SyntaxError):
77
- return val
78
-
79
- average_rent = reordered_df_properties_filtered['rent_combined'].mean()
80
-
81
- x1 ="Comps " + str(average_rent)
82
- x3="Rent " + str(st.session_state['prediction'])
83
-
84
- # x2 = (st.session_state['prediction']+average_rent)/2
85
-
86
- pick = st.select_slider(
87
- "Combined estimation ",
88
- options=[x1, x3],
89
- value=x1)
90
-
91
- back_to_serach_tab1 = st.button("Search page")
92
- if back_to_serach_tab1:
93
- st.switch_page("app.py")
94
 
95
  #comps page
96
  with tab1:
@@ -134,7 +81,12 @@ def main():
134
  col_1_1, col_1_2 = st.columns([2, 1])
135
  with col_1_1:
136
  st.write('Comps list:')
137
- display_df = st.table(filtered_data)
 
 
 
 
 
138
  with col_1_2:
139
  # Create a map object
140
  m = folium.Map(width=500, height=440, location=(reordered_df_properties_filtered['lat'].mean(), reordered_df_properties_filtered['long'].mean()), zoom_start=9)
@@ -195,6 +147,61 @@ def main():
195
  if back_to_serach_tab2:
196
  st.switch_page("app.py")
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
 
199
  if __name__ == "__main__":
200
  main()
 
38
  sorted_indexes = df_properties_filtered.index[sorted_indices]
39
  reordered_df_properties_filtered = df_properties_filtered.loc[sorted_indexes]
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  #comps page
43
  with tab1:
 
81
  col_1_1, col_1_2 = st.columns([2, 1])
82
  with col_1_1:
83
  st.write('Comps list:')
84
+ sort_column = st.selectbox('Select column to sort by:', filtered_data.columns[1:])
85
+ # display_df = st.table(filtered_data)
86
+ if sort_column:
87
+ filtered_data_sorted = filtered_data.sort_values(by=sort_column, ascending=False)
88
+ st.dataframe(filtered_data_sorted)
89
+
90
  with col_1_2:
91
  # Create a map object
92
  m = folium.Map(width=500, height=440, location=(reordered_df_properties_filtered['lat'].mean(), reordered_df_properties_filtered['long'].mean()), zoom_start=9)
 
147
  if back_to_serach_tab2:
148
  st.switch_page("app.py")
149
 
150
+ with tab2:
151
+ st.title('Combined estimation')
152
+ if 'user_select_value' not in st.session_state:
153
+ st.session_state['user_select_value'] = ""
154
+ if 'year_buit' not in st.session_state:
155
+ st.session_state['year_buit'] = ""
156
+ if 'submarket_val' not in st.session_state:
157
+ st.session_state['submarket_val'] = ""
158
+ if 'market_val' not in st.session_state:
159
+ st.session_state['market_val'] = ""
160
+
161
+ box_contents = [
162
+ {"header": "Address", "content": st.session_state['user_select_value']},
163
+ {"header": "LSF", "content": str(st.session_state['property_lsf'])},
164
+ {"header": "Sub-Market", "content": st.session_state['submarket_val']},
165
+ {"header": "Market", "content": st.session_state['market_val']}
166
+ ]
167
+
168
+ # Divide the layout into four columns
169
+ col1, col2, col3, col4 = st.columns(4)
170
+
171
+ for i, col in enumerate([col1, col2, col3, col4]):
172
+ col.markdown(f"""
173
+ <div style="padding: 20px; margin: 10px; text-align: center;">
174
+ <h3 style="font-size: small;">{box_contents[i]['header']}</h3>
175
+ <p style="font-size: small;">{box_contents[i]['content']}</p>
176
+ </div>
177
+ """, unsafe_allow_html=True)
178
+
179
+ # Add padding between the boxes and the slider
180
+ st.markdown('<style>div[data-testid="stBlock"]{margin-top: 20px;}</style>', unsafe_allow_html=True)
181
+
182
+ def safe_eval(val):
183
+ try:
184
+ return ast.literal_eval(val)
185
+ except (ValueError, SyntaxError):
186
+ return val
187
+
188
+ average_rent = reordered_df_properties_filtered['rent_combined'].mean()
189
+
190
+ x1 ="Comps " + str(average_rent)
191
+ x3="Rent " + str(st.session_state['prediction'])
192
+
193
+ # x2 = (st.session_state['prediction']+average_rent)/2
194
+
195
+ pick = st.select_slider(
196
+ "Combined estimation ",
197
+ options=[x1, x3],
198
+ value=x1)
199
+
200
+ back_to_serach_tab1 = st.button("Search page")
201
+ if back_to_serach_tab1:
202
+ st.switch_page("app.py")
203
+
204
+
205
 
206
  if __name__ == "__main__":
207
  main()