giswqs commited on
Commit
bacdc00
·
1 Parent(s): c9d5073

Fixed layout

Browse files
Files changed (2) hide show
  1. apps/housing.py +41 -24
  2. data/realtor_data_dict.csv +18 -18
apps/housing.py CHANGED
@@ -100,8 +100,9 @@ def select_null(gdf, col_name):
100
  def get_data_dict(name):
101
  in_csv = os.path.join(os.getcwd(), "data/realtor_data_dict.csv")
102
  df = pd.read_csv(in_csv)
 
103
  desc = list(df[df["Name"] == name]["Description"])[0]
104
- return desc
105
 
106
 
107
  def app():
@@ -114,15 +115,6 @@ def app():
114
  """
115
  )
116
 
117
- col1, col2, col3 = st.columns(3)
118
-
119
- with col1:
120
- frequency = st.radio("", ["Monthly", "Weekly"])
121
- with col2:
122
- st.radio("", ["Current month data", "Historical data"])
123
- with col3:
124
- st.radio("", ["National", "State", "Metro", "County", "Zip"], index=3)
125
-
126
  county_gdf = get_geom_data("county")
127
  inventory_df = get_inventory_data(
128
  data_links["monthly_current"]["county"], "county_fips"
@@ -130,19 +122,39 @@ def app():
130
 
131
  data_cols = get_data_columns(inventory_df, "county")
132
 
133
- row2_col1, row2_col2, row2_col3, row2_col4 = st.columns([1.3, 1, 1, 3])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
  with row2_col1:
136
- selected_col = st.selectbox("Select an attribute", data_cols)
137
- # with st.expander("See description"):
138
- # st.write(get_data_dict(selected_col.strip()))
139
-
140
- with row2_col2:
141
  palette = st.selectbox(
142
- "Select a palette", cm.list_colormaps(), index=2)
143
- with row2_col3:
144
  n_colors = st.slider("Number of colors", min_value=2,
145
  max_value=20, value=8)
 
 
 
 
146
 
147
  county_gdf = join_attributes(county_gdf, inventory_df, "county")
148
  county_gdf = select_non_null(county_gdf, selected_col)
@@ -201,11 +213,11 @@ def app():
201
  tooltip=tooltip,
202
  )
203
 
204
- col4, col5 = st.columns([6, 1])
205
 
206
- with col4:
207
  st.pydeck_chart(r)
208
- with col5:
209
  st.write(
210
  cm.create_colormap(
211
  palette,
@@ -215,8 +227,13 @@ def app():
215
  orientation="vertical",
216
  vmin=min_value,
217
  vmax=max_value,
 
218
  )
219
  )
220
- st.dataframe(county_gdf.drop(columns=["geometry"]))
221
- # st.dataframe(inventory_df)
222
- # st.write(cm.plot_colormaps(return_fig=True))
 
 
 
 
 
100
  def get_data_dict(name):
101
  in_csv = os.path.join(os.getcwd(), "data/realtor_data_dict.csv")
102
  df = pd.read_csv(in_csv)
103
+ label = list(df[df["Name"] == name]["Label"])[0]
104
  desc = list(df[df["Name"] == name]["Description"])[0]
105
+ return label, desc
106
 
107
 
108
  def app():
 
115
  """
116
  )
117
 
 
 
 
 
 
 
 
 
 
118
  county_gdf = get_geom_data("county")
119
  inventory_df = get_inventory_data(
120
  data_links["monthly_current"]["county"], "county_fips"
 
122
 
123
  data_cols = get_data_columns(inventory_df, "county")
124
 
125
+ row1_col1, row1_col2, row1_col3, row1_col4, row1_col5 = st.columns([
126
+ 0.6, 0.8, 0.6, 1.4, 2])
127
+ with row1_col1:
128
+ frequency = st.selectbox("Monthly/weekly data", ["Monthly", "Weekly"])
129
+ with row1_col2:
130
+ st.selectbox("Current/historical data",
131
+ ["Current month data", "Historical data"])
132
+ with row1_col3:
133
+ st.selectbox("Scale", ["National", "State", "Metro",
134
+ "County", "Zip"], index=3)
135
+ with row1_col4:
136
+ selected_col = st.selectbox("Attribute", data_cols)
137
+ with row1_col5:
138
+ show_desc = st.checkbox("Show data description")
139
+ if show_desc:
140
+ label, desc = get_data_dict(selected_col.strip())
141
+ markdown = f"""
142
+ **{label}**: {desc}
143
+ """
144
+ st.markdown(markdown)
145
+
146
+ row2_col1, row2_col2, row2_col3, row2_col4 = st.columns([1, 1, 2, 2])
147
 
148
  with row2_col1:
 
 
 
 
 
149
  palette = st.selectbox(
150
+ "Color palette", cm.list_colormaps(), index=2)
151
+ with row2_col2:
152
  n_colors = st.slider("Number of colors", min_value=2,
153
  max_value=20, value=8)
154
+ with row2_col3:
155
+ show_colormaps = st.checkbox("Preview all colormaps")
156
+ if show_colormaps:
157
+ st.write(cm.plot_colormaps(return_fig=True))
158
 
159
  county_gdf = join_attributes(county_gdf, inventory_df, "county")
160
  county_gdf = select_non_null(county_gdf, selected_col)
 
213
  tooltip=tooltip,
214
  )
215
 
216
+ row3_col1, row3_col2 = st.columns([6, 1])
217
 
218
+ with row3_col1:
219
  st.pydeck_chart(r)
220
+ with row3_col2:
221
  st.write(
222
  cm.create_colormap(
223
  palette,
 
227
  orientation="vertical",
228
  vmin=min_value,
229
  vmax=max_value,
230
+ font_size=10
231
  )
232
  )
233
+ row4_col1, row4_col2, _ = st.columns([1, 2, 3])
234
+ with row4_col1:
235
+ show_data = st.checkbox("Show data")
236
+ with row4_col2:
237
+ show_cols = st.multiselect("Select columns", data_cols)
238
+ if show_data:
239
+ st.dataframe(county_gdf[["STATEFP", "COUNTYFP", "NAME"] + show_cols])
data/realtor_data_dict.csv CHANGED
@@ -5,30 +5,30 @@ median_listing_price_yy,Median Listing Price Y/Y,The percentage change in the me
5
  active_listing_count,Active Listing Count,"The count of active listings within the specified geography during the specified month. The active listing count tracks the number of for sale properties on the market, excluding pending listings where a pending status is available. This is a snapshot measure of how many active listings can be expected on any given day of the specified month."
6
  active_listing_count_mm,Active Listing Count M/M,The percentage change in the active listing count from the previous month.
7
  active_listing_count_yy,Active Listing Count Y/Y,The percentage change in the active listing count from the same month in the previous year.
8
- days_on_market,Days on Market,The median number of days property listings spend on the market within the specified geography during the specified month. Time spent on the market is defined as the time between the initial listing of a property and either its closing date or the date it is taken off the market.
9
- days_on_market_mm,Days on Market M/M,The percentage change in the median days on market from the previous month.
10
- days_on_market_yy,Days on Market Y/Y,The percentage change in the median days on market from the same month in the previous year.
11
  new_listing_count,New Listing Count,The count of new listings added to the market within the specified geography. The new listing count represents a typical week’s worth of new listings in a given month. The new listing count can be multiplied by the number of weeks in a month to produce a monthly new listing count.
12
  new_listing_count_mm,New Listing Count M/M,The percentage change in the new listing count from the previous month.
13
  new_listing_count_yy,New Listing Count Y/Y,The percentage change in the new listing count from the same month in the previous year.
14
- price_increase_count,Price Increase Count,The count of listings which have had their price increased within the specified geography. The price increase count represents a typical week’s worth of listings which have had their price increased in a given month. The price increase count can be multiplied by the number of weeks in a month to produce a monthly price increase count.
15
- price_increase_count_mm,Price Increase Count M/M,The percentage change in the price increase count from the previous month.
16
- price_increase_count_yy,Price Increase Count Y/Y,The percentage change in the price increase count from the same month in the previous year.
17
- price_decrease_count,Price Decrease Count,The count of listings which have had their price reduced within the specified geography. The price decrease count represents a typical week’s worth of listings which have had their price reduced in a given month. The price decrease count can be multiplied by the number of weeks in a month to produce a monthly price decrease count.
18
- price_decrease_count_mm,Price Decrease Count M/M,The percentage change in the price decrease count from the previous month.
19
- price_decrease_count_yy,Price Decrease Count Y/Y,The percentage change in the price decrease count from the same month in the previous year.
20
  pending_listing_count,Pending Listing Count,"The count of pending listings within the specified geography during the specified month, if a pending definition is available for that geography. This is a snapshot measure of how many pending listings can be expected on any given day of the specified month."
21
  pending_listing_count_mm,Pending Listing Count M/M,The percentage change in the pending listing count from the previous month.
22
  pending_listing_count_yy,Pending Listing Count Y/Y,The percentage change in the pending listing count from the same month in the previous year.
23
- median_list_price_per_sqft,Median List Price Per Sqft,The median listing price per square foot within the specified geography during the specified month.
24
- median_list_price_per_sqft_mm,Median List Price Per Sqft M/M,The percentage change in the median listing price per square foot from the previous month.
25
- median_list_price_per_sqft_yy,Median List Price Per Sqft Y/Y,The percentage change in the median listing price per square foot from the same month in the previous year.
26
- median_listing_sqft,Median Listing Sqft,The median listing square feet within the specified geography during the specified month.
27
- median_listing_sqft_mm,Median Listing Sqft M/M,The percentage change in the median listing square feet from the previous month.
28
- median_listing_sqft_yy,Median Listing Sqft Y/Y,The percentage change in the median listing square feet from the same month in the previous year.
29
- avg_listing_price,Avg Listing Price,The average listing price within the specified geography during the specified month.
30
- avg_listing_price_mm,Avg Listing Price M/M,The percentage change in the average listing price from the previous month.
31
- avg_listing_price_yy,Avg Listing Price Y/Y,The percentage change in the average listing price from the same month in the previous year.
32
  total_listing_count,Total Listing Count,The total of both active listings and pending listings within the specified geography during the specified month. This is a snapshot measure of how many total listings can be expected on any given day of the specified month.
33
  total_listing_count_mm,Total Listing Count M/M,The percentage change in the total listing count from the previous month.
34
  total_listing_count_yy,Total Listing Count Y/Y,The percentage change in the total listing count from the same month in the previous year.
 
5
  active_listing_count,Active Listing Count,"The count of active listings within the specified geography during the specified month. The active listing count tracks the number of for sale properties on the market, excluding pending listings where a pending status is available. This is a snapshot measure of how many active listings can be expected on any given day of the specified month."
6
  active_listing_count_mm,Active Listing Count M/M,The percentage change in the active listing count from the previous month.
7
  active_listing_count_yy,Active Listing Count Y/Y,The percentage change in the active listing count from the same month in the previous year.
8
+ median_days_on_market,Days on Market,The median number of days property listings spend on the market within the specified geography during the specified month. Time spent on the market is defined as the time between the initial listing of a property and either its closing date or the date it is taken off the market.
9
+ median_days_on_market_mm,Days on Market M/M,The percentage change in the median days on market from the previous month.
10
+ median_days_on_market_yy,Days on Market Y/Y,The percentage change in the median days on market from the same month in the previous year.
11
  new_listing_count,New Listing Count,The count of new listings added to the market within the specified geography. The new listing count represents a typical week’s worth of new listings in a given month. The new listing count can be multiplied by the number of weeks in a month to produce a monthly new listing count.
12
  new_listing_count_mm,New Listing Count M/M,The percentage change in the new listing count from the previous month.
13
  new_listing_count_yy,New Listing Count Y/Y,The percentage change in the new listing count from the same month in the previous year.
14
+ price_increased_count,Price Increase Count,The count of listings which have had their price increased within the specified geography. The price increase count represents a typical week’s worth of listings which have had their price increased in a given month. The price increase count can be multiplied by the number of weeks in a month to produce a monthly price increase count.
15
+ price_increased_count_mm,Price Increase Count M/M,The percentage change in the price increase count from the previous month.
16
+ price_increased_count_yy,Price Increase Count Y/Y,The percentage change in the price increase count from the same month in the previous year.
17
+ price_reduced_count,Price Decrease Count,The count of listings which have had their price reduced within the specified geography. The price decrease count represents a typical week’s worth of listings which have had their price reduced in a given month. The price decrease count can be multiplied by the number of weeks in a month to produce a monthly price decrease count.
18
+ price_reduced_count_mm,Price Decrease Count M/M,The percentage change in the price decrease count from the previous month.
19
+ price_reduced_count_yy,Price Decrease Count Y/Y,The percentage change in the price decrease count from the same month in the previous year.
20
  pending_listing_count,Pending Listing Count,"The count of pending listings within the specified geography during the specified month, if a pending definition is available for that geography. This is a snapshot measure of how many pending listings can be expected on any given day of the specified month."
21
  pending_listing_count_mm,Pending Listing Count M/M,The percentage change in the pending listing count from the previous month.
22
  pending_listing_count_yy,Pending Listing Count Y/Y,The percentage change in the pending listing count from the same month in the previous year.
23
+ median_listing_price_per_square_foot,Median List Price Per Sqft,The median listing price per square foot within the specified geography during the specified month.
24
+ median_listing_price_per_square_foot_mm,Median List Price Per Sqft M/M,The percentage change in the median listing price per square foot from the previous month.
25
+ median_listing_price_per_square_foot_yy,Median List Price Per Sqft Y/Y,The percentage change in the median listing price per square foot from the same month in the previous year.
26
+ median_square_feet,Median Listing Sqft,The median listing square feet within the specified geography during the specified month.
27
+ median_square_feet_mm,Median Listing Sqft M/M,The percentage change in the median listing square feet from the previous month.
28
+ median_square_feet_yy,Median Listing Sqft Y/Y,The percentage change in the median listing square feet from the same month in the previous year.
29
+ average_listing_price,Avg Listing Price,The average listing price within the specified geography during the specified month.
30
+ average_listing_price_mm,Avg Listing Price M/M,The percentage change in the average listing price from the previous month.
31
+ average_listing_price_yy,Avg Listing Price Y/Y,The percentage change in the average listing price from the same month in the previous year.
32
  total_listing_count,Total Listing Count,The total of both active listings and pending listings within the specified geography during the specified month. This is a snapshot measure of how many total listings can be expected on any given day of the specified month.
33
  total_listing_count_mm,Total Listing Count M/M,The percentage change in the total listing count from the previous month.
34
  total_listing_count_yy,Total Listing Count Y/Y,The percentage change in the total listing count from the same month in the previous year.