misikoff commited on
Commit
ebc591b
1 Parent(s): 4b69ce5

small upload

Browse files
.gitattributes CHANGED
@@ -53,4 +53,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
 
56
  *.jsonl filter=lfs diff=lfs merge=lfs -text
 
 
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
56
+ # Project file formats
57
  *.jsonl filter=lfs diff=lfs merge=lfs -text
58
+ *.csv filter=lfs diff=lfs merge=lfs -text
processors/days_on_market.ipynb ADDED
@@ -0,0 +1,798 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 3,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import pandas as pd\n",
10
+ "import os"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 4,
16
+ "metadata": {},
17
+ "outputs": [],
18
+ "source": [
19
+ "DATA_DIR = \"../data\"\n",
20
+ "PROCESSED_DIR = \"../processed/\"\n",
21
+ "FACET_DIR = \"days_on_market/\"\n",
22
+ "FULL_DATA_DIR_PATH = os.path.join(DATA_DIR, FACET_DIR)\n",
23
+ "FULL_PROCESSED_DIR_PATH = os.path.join(PROCESSED_DIR, FACET_DIR)"
24
+ ]
25
+ },
26
+ {
27
+ "cell_type": "code",
28
+ "execution_count": 7,
29
+ "metadata": {},
30
+ "outputs": [
31
+ {
32
+ "name": "stdout",
33
+ "output_type": "stream",
34
+ "text": [
35
+ "dict_values(['Mean Listings Price Cut Amount', 'Median Days on Pending', 'Median Days to Close', 'Percent Listings Price Cut'])\n"
36
+ ]
37
+ },
38
+ {
39
+ "data": {
40
+ "text/html": [
41
+ "<div>\n",
42
+ "<style scoped>\n",
43
+ " .dataframe tbody tr th:only-of-type {\n",
44
+ " vertical-align: middle;\n",
45
+ " }\n",
46
+ "\n",
47
+ " .dataframe tbody tr th {\n",
48
+ " vertical-align: top;\n",
49
+ " }\n",
50
+ "\n",
51
+ " .dataframe thead th {\n",
52
+ " text-align: right;\n",
53
+ " }\n",
54
+ "</style>\n",
55
+ "<table border=\"1\" class=\"dataframe\">\n",
56
+ " <thead>\n",
57
+ " <tr style=\"text-align: right;\">\n",
58
+ " <th></th>\n",
59
+ " <th>RegionID</th>\n",
60
+ " <th>SizeRank</th>\n",
61
+ " <th>RegionName</th>\n",
62
+ " <th>RegionType</th>\n",
63
+ " <th>StateName</th>\n",
64
+ " <th>Home Type</th>\n",
65
+ " <th>Date</th>\n",
66
+ " <th>Mean Listings Price Cut Amount (Smoothed)</th>\n",
67
+ " <th>Percent Listings Price Cut</th>\n",
68
+ " <th>Mean Listings Price Cut Amount</th>\n",
69
+ " <th>Percent Listings Price Cut (Smoothed)</th>\n",
70
+ " <th>Median Days on Pending (Smoothed)</th>\n",
71
+ " <th>Median Days on Pending</th>\n",
72
+ " </tr>\n",
73
+ " </thead>\n",
74
+ " <tbody>\n",
75
+ " <tr>\n",
76
+ " <th>0</th>\n",
77
+ " <td>102001</td>\n",
78
+ " <td>0</td>\n",
79
+ " <td>United States</td>\n",
80
+ " <td>country</td>\n",
81
+ " <td>NaN</td>\n",
82
+ " <td>SFR</td>\n",
83
+ " <td>2018-01-06</td>\n",
84
+ " <td>NaN</td>\n",
85
+ " <td>NaN</td>\n",
86
+ " <td>13508.368375</td>\n",
87
+ " <td>NaN</td>\n",
88
+ " <td>NaN</td>\n",
89
+ " <td>NaN</td>\n",
90
+ " </tr>\n",
91
+ " <tr>\n",
92
+ " <th>1</th>\n",
93
+ " <td>102001</td>\n",
94
+ " <td>0</td>\n",
95
+ " <td>United States</td>\n",
96
+ " <td>country</td>\n",
97
+ " <td>NaN</td>\n",
98
+ " <td>SFR</td>\n",
99
+ " <td>2018-01-13</td>\n",
100
+ " <td>NaN</td>\n",
101
+ " <td>0.049042</td>\n",
102
+ " <td>14114.788383</td>\n",
103
+ " <td>NaN</td>\n",
104
+ " <td>NaN</td>\n",
105
+ " <td>NaN</td>\n",
106
+ " </tr>\n",
107
+ " <tr>\n",
108
+ " <th>2</th>\n",
109
+ " <td>102001</td>\n",
110
+ " <td>0</td>\n",
111
+ " <td>United States</td>\n",
112
+ " <td>country</td>\n",
113
+ " <td>NaN</td>\n",
114
+ " <td>SFR</td>\n",
115
+ " <td>2018-01-20</td>\n",
116
+ " <td>NaN</td>\n",
117
+ " <td>0.044740</td>\n",
118
+ " <td>14326.128956</td>\n",
119
+ " <td>NaN</td>\n",
120
+ " <td>NaN</td>\n",
121
+ " <td>NaN</td>\n",
122
+ " </tr>\n",
123
+ " <tr>\n",
124
+ " <th>3</th>\n",
125
+ " <td>102001</td>\n",
126
+ " <td>0</td>\n",
127
+ " <td>United States</td>\n",
128
+ " <td>country</td>\n",
129
+ " <td>NaN</td>\n",
130
+ " <td>SFR</td>\n",
131
+ " <td>2018-01-27</td>\n",
132
+ " <td>NaN</td>\n",
133
+ " <td>0.047930</td>\n",
134
+ " <td>13998.585612</td>\n",
135
+ " <td>NaN</td>\n",
136
+ " <td>NaN</td>\n",
137
+ " <td>NaN</td>\n",
138
+ " </tr>\n",
139
+ " <tr>\n",
140
+ " <th>4</th>\n",
141
+ " <td>102001</td>\n",
142
+ " <td>0</td>\n",
143
+ " <td>United States</td>\n",
144
+ " <td>country</td>\n",
145
+ " <td>NaN</td>\n",
146
+ " <td>SFR</td>\n",
147
+ " <td>2018-02-03</td>\n",
148
+ " <td>NaN</td>\n",
149
+ " <td>0.047622</td>\n",
150
+ " <td>14120.035549</td>\n",
151
+ " <td>NaN</td>\n",
152
+ " <td>NaN</td>\n",
153
+ " <td>NaN</td>\n",
154
+ " </tr>\n",
155
+ " <tr>\n",
156
+ " <th>...</th>\n",
157
+ " <td>...</td>\n",
158
+ " <td>...</td>\n",
159
+ " <td>...</td>\n",
160
+ " <td>...</td>\n",
161
+ " <td>...</td>\n",
162
+ " <td>...</td>\n",
163
+ " <td>...</td>\n",
164
+ " <td>...</td>\n",
165
+ " <td>...</td>\n",
166
+ " <td>...</td>\n",
167
+ " <td>...</td>\n",
168
+ " <td>...</td>\n",
169
+ " <td>...</td>\n",
170
+ " </tr>\n",
171
+ " <tr>\n",
172
+ " <th>586709</th>\n",
173
+ " <td>845172</td>\n",
174
+ " <td>769</td>\n",
175
+ " <td>Winfield, KS</td>\n",
176
+ " <td>msa</td>\n",
177
+ " <td>KS</td>\n",
178
+ " <td>all homes (SFR + Condo)</td>\n",
179
+ " <td>2024-01-06</td>\n",
180
+ " <td>NaN</td>\n",
181
+ " <td>0.094017</td>\n",
182
+ " <td>NaN</td>\n",
183
+ " <td>0.037378</td>\n",
184
+ " <td>NaN</td>\n",
185
+ " <td>NaN</td>\n",
186
+ " </tr>\n",
187
+ " <tr>\n",
188
+ " <th>586710</th>\n",
189
+ " <td>845172</td>\n",
190
+ " <td>769</td>\n",
191
+ " <td>Winfield, KS</td>\n",
192
+ " <td>msa</td>\n",
193
+ " <td>KS</td>\n",
194
+ " <td>all homes (SFR + Condo)</td>\n",
195
+ " <td>2024-01-13</td>\n",
196
+ " <td>NaN</td>\n",
197
+ " <td>0.070175</td>\n",
198
+ " <td>NaN</td>\n",
199
+ " <td>0.043203</td>\n",
200
+ " <td>NaN</td>\n",
201
+ " <td>NaN</td>\n",
202
+ " </tr>\n",
203
+ " <tr>\n",
204
+ " <th>586711</th>\n",
205
+ " <td>845172</td>\n",
206
+ " <td>769</td>\n",
207
+ " <td>Winfield, KS</td>\n",
208
+ " <td>msa</td>\n",
209
+ " <td>KS</td>\n",
210
+ " <td>all homes (SFR + Condo)</td>\n",
211
+ " <td>2024-01-20</td>\n",
212
+ " <td>NaN</td>\n",
213
+ " <td>0.043478</td>\n",
214
+ " <td>NaN</td>\n",
215
+ " <td>0.054073</td>\n",
216
+ " <td>NaN</td>\n",
217
+ " <td>NaN</td>\n",
218
+ " </tr>\n",
219
+ " <tr>\n",
220
+ " <th>586712</th>\n",
221
+ " <td>845172</td>\n",
222
+ " <td>769</td>\n",
223
+ " <td>Winfield, KS</td>\n",
224
+ " <td>msa</td>\n",
225
+ " <td>KS</td>\n",
226
+ " <td>all homes (SFR + Condo)</td>\n",
227
+ " <td>2024-01-27</td>\n",
228
+ " <td>NaN</td>\n",
229
+ " <td>0.036697</td>\n",
230
+ " <td>NaN</td>\n",
231
+ " <td>0.061092</td>\n",
232
+ " <td>NaN</td>\n",
233
+ " <td>NaN</td>\n",
234
+ " </tr>\n",
235
+ " <tr>\n",
236
+ " <th>586713</th>\n",
237
+ " <td>845172</td>\n",
238
+ " <td>769</td>\n",
239
+ " <td>Winfield, KS</td>\n",
240
+ " <td>msa</td>\n",
241
+ " <td>KS</td>\n",
242
+ " <td>all homes (SFR + Condo)</td>\n",
243
+ " <td>2024-02-03</td>\n",
244
+ " <td>NaN</td>\n",
245
+ " <td>0.077670</td>\n",
246
+ " <td>NaN</td>\n",
247
+ " <td>0.057005</td>\n",
248
+ " <td>NaN</td>\n",
249
+ " <td>NaN</td>\n",
250
+ " </tr>\n",
251
+ " </tbody>\n",
252
+ "</table>\n",
253
+ "<p>586714 rows × 13 columns</p>\n",
254
+ "</div>"
255
+ ],
256
+ "text/plain": [
257
+ " RegionID SizeRank RegionName RegionType StateName \\\n",
258
+ "0 102001 0 United States country NaN \n",
259
+ "1 102001 0 United States country NaN \n",
260
+ "2 102001 0 United States country NaN \n",
261
+ "3 102001 0 United States country NaN \n",
262
+ "4 102001 0 United States country NaN \n",
263
+ "... ... ... ... ... ... \n",
264
+ "586709 845172 769 Winfield, KS msa KS \n",
265
+ "586710 845172 769 Winfield, KS msa KS \n",
266
+ "586711 845172 769 Winfield, KS msa KS \n",
267
+ "586712 845172 769 Winfield, KS msa KS \n",
268
+ "586713 845172 769 Winfield, KS msa KS \n",
269
+ "\n",
270
+ " Home Type Date \\\n",
271
+ "0 SFR 2018-01-06 \n",
272
+ "1 SFR 2018-01-13 \n",
273
+ "2 SFR 2018-01-20 \n",
274
+ "3 SFR 2018-01-27 \n",
275
+ "4 SFR 2018-02-03 \n",
276
+ "... ... ... \n",
277
+ "586709 all homes (SFR + Condo) 2024-01-06 \n",
278
+ "586710 all homes (SFR + Condo) 2024-01-13 \n",
279
+ "586711 all homes (SFR + Condo) 2024-01-20 \n",
280
+ "586712 all homes (SFR + Condo) 2024-01-27 \n",
281
+ "586713 all homes (SFR + Condo) 2024-02-03 \n",
282
+ "\n",
283
+ " Mean Listings Price Cut Amount (Smoothed) Percent Listings Price Cut \\\n",
284
+ "0 NaN NaN \n",
285
+ "1 NaN 0.049042 \n",
286
+ "2 NaN 0.044740 \n",
287
+ "3 NaN 0.047930 \n",
288
+ "4 NaN 0.047622 \n",
289
+ "... ... ... \n",
290
+ "586709 NaN 0.094017 \n",
291
+ "586710 NaN 0.070175 \n",
292
+ "586711 NaN 0.043478 \n",
293
+ "586712 NaN 0.036697 \n",
294
+ "586713 NaN 0.077670 \n",
295
+ "\n",
296
+ " Mean Listings Price Cut Amount Percent Listings Price Cut (Smoothed) \\\n",
297
+ "0 13508.368375 NaN \n",
298
+ "1 14114.788383 NaN \n",
299
+ "2 14326.128956 NaN \n",
300
+ "3 13998.585612 NaN \n",
301
+ "4 14120.035549 NaN \n",
302
+ "... ... ... \n",
303
+ "586709 NaN 0.037378 \n",
304
+ "586710 NaN 0.043203 \n",
305
+ "586711 NaN 0.054073 \n",
306
+ "586712 NaN 0.061092 \n",
307
+ "586713 NaN 0.057005 \n",
308
+ "\n",
309
+ " Median Days on Pending (Smoothed) Median Days on Pending \n",
310
+ "0 NaN NaN \n",
311
+ "1 NaN NaN \n",
312
+ "2 NaN NaN \n",
313
+ "3 NaN NaN \n",
314
+ "4 NaN NaN \n",
315
+ "... ... ... \n",
316
+ "586709 NaN NaN \n",
317
+ "586710 NaN NaN \n",
318
+ "586711 NaN NaN \n",
319
+ "586712 NaN NaN \n",
320
+ "586713 NaN NaN \n",
321
+ "\n",
322
+ "[586714 rows x 13 columns]"
323
+ ]
324
+ },
325
+ "execution_count": 7,
326
+ "metadata": {},
327
+ "output_type": "execute_result"
328
+ }
329
+ ],
330
+ "source": [
331
+ "data_frames = []\n",
332
+ "\n",
333
+ "exclude_columns = [\n",
334
+ " \"RegionID\",\n",
335
+ " \"SizeRank\",\n",
336
+ " \"RegionName\",\n",
337
+ " \"RegionType\",\n",
338
+ " \"StateName\",\n",
339
+ " \"Home Type\",\n",
340
+ "]\n",
341
+ "\n",
342
+ "slug_column_mappings = {\n",
343
+ " \"_mean_listings_price_cut_amt_\": \"Mean Listings Price Cut Amount\",\n",
344
+ " \"_med_doz_pending_\": \"Median Days on Pending\",\n",
345
+ " \"_median_days_to_pending_\": \"Median Days to Close\",\n",
346
+ " \"_perc_listings_price_cut_\": \"Percent Listings Price Cut\",\n",
347
+ "}\n",
348
+ "\n",
349
+ "\n",
350
+ "def get_df(\n",
351
+ " df, exclude_columns, columns_to_pivot, col_name, smoothed, seasonally_adjusted\n",
352
+ "):\n",
353
+ " if smoothed:\n",
354
+ " col_name += \" (Smoothed)\"\n",
355
+ " if seasonally_adjusted:\n",
356
+ " col_name += \" (Seasonally Adjusted)\"\n",
357
+ "\n",
358
+ " df = pd.melt(\n",
359
+ " df,\n",
360
+ " id_vars=exclude_columns,\n",
361
+ " value_vars=columns_to_pivot,\n",
362
+ " var_name=\"Date\",\n",
363
+ " value_name=col_name,\n",
364
+ " )\n",
365
+ " return df\n",
366
+ "\n",
367
+ "\n",
368
+ "for filename in os.listdir(FULL_DATA_DIR_PATH):\n",
369
+ " if filename.endswith(\".csv\"):\n",
370
+ " # print(\"processing \" + filename)\n",
371
+ " cur_df = pd.read_csv(os.path.join(FULL_DATA_DIR_PATH, filename))\n",
372
+ "\n",
373
+ " # skip month files for now since they are redundant\n",
374
+ " if \"month\" in filename:\n",
375
+ " continue\n",
376
+ "\n",
377
+ " if \"_uc_sfrcondo_\" in filename:\n",
378
+ " cur_df[\"Home Type\"] = \"all homes (SFR + Condo)\"\n",
379
+ " # change column type to string\n",
380
+ " cur_df[\"RegionName\"] = cur_df[\"RegionName\"].astype(str)\n",
381
+ " elif \"_uc_sfr_\" in filename:\n",
382
+ " cur_df[\"Home Type\"] = \"SFR\"\n",
383
+ "\n",
384
+ " # Identify columns to pivot\n",
385
+ " columns_to_pivot = [col for col in cur_df.columns if col not in exclude_columns]\n",
386
+ "\n",
387
+ " smoothed = \"_sm_\" in filename\n",
388
+ " seasonally_adjusted = \"_sa_\" in filename\n",
389
+ "\n",
390
+ " # iterate over slug column mappings and get df\n",
391
+ " for slug, col_name in slug_column_mappings.items():\n",
392
+ " if slug in filename:\n",
393
+ " cur_df = get_df(\n",
394
+ " cur_df,\n",
395
+ " exclude_columns,\n",
396
+ " columns_to_pivot,\n",
397
+ " col_name,\n",
398
+ " smoothed,\n",
399
+ " seasonally_adjusted,\n",
400
+ " )\n",
401
+ "\n",
402
+ " data_frames.append(cur_df)\n",
403
+ " break\n",
404
+ "\n",
405
+ "\n",
406
+ "def get_combined_df(data_frames):\n",
407
+ " combined_df = None\n",
408
+ " if len(data_frames) > 1:\n",
409
+ " # iterate over dataframes and merge or concat\n",
410
+ " combined_df = data_frames[0]\n",
411
+ " for i in range(1, len(data_frames)):\n",
412
+ " cur_df = data_frames[i]\n",
413
+ " combined_df = pd.merge(\n",
414
+ " combined_df,\n",
415
+ " cur_df,\n",
416
+ " on=[\n",
417
+ " \"RegionID\",\n",
418
+ " \"SizeRank\",\n",
419
+ " \"RegionName\",\n",
420
+ " \"RegionType\",\n",
421
+ " \"StateName\",\n",
422
+ " \"Home Type\",\n",
423
+ " \"Date\",\n",
424
+ " ],\n",
425
+ " how=\"outer\",\n",
426
+ " suffixes=(\"\", \"_\" + str(i)),\n",
427
+ " )\n",
428
+ " elif len(data_frames) == 1:\n",
429
+ " combined_df = data_frames[0]\n",
430
+ "\n",
431
+ " return combined_df\n",
432
+ "\n",
433
+ "\n",
434
+ "combined_df = get_combined_df(data_frames)\n",
435
+ "\n",
436
+ "# iterate over rows of combined df and coalesce column values across columns that start with \"Median Sale Price\"\n",
437
+ "columns_to_coalesce = slug_column_mappings.values()\n",
438
+ "print(columns_to_coalesce)\n",
439
+ "\n",
440
+ "for index, row in combined_df.iterrows():\n",
441
+ " for col in combined_df.columns:\n",
442
+ " for column_to_coalesce in columns_to_coalesce:\n",
443
+ " if column_to_coalesce in col and \"_\" in col:\n",
444
+ " if not pd.isna(row[col]):\n",
445
+ " combined_df.at[index, column_to_coalesce] = row[col]\n",
446
+ "\n",
447
+ "# remove columns with underscores\n",
448
+ "combined_df = combined_df[[col for col in combined_df.columns if \"_\" not in col]]\n",
449
+ "\n",
450
+ "combined_df"
451
+ ]
452
+ },
453
+ {
454
+ "cell_type": "code",
455
+ "execution_count": 16,
456
+ "metadata": {},
457
+ "outputs": [
458
+ {
459
+ "data": {
460
+ "text/html": [
461
+ "<div>\n",
462
+ "<style scoped>\n",
463
+ " .dataframe tbody tr th:only-of-type {\n",
464
+ " vertical-align: middle;\n",
465
+ " }\n",
466
+ "\n",
467
+ " .dataframe tbody tr th {\n",
468
+ " vertical-align: top;\n",
469
+ " }\n",
470
+ "\n",
471
+ " .dataframe thead th {\n",
472
+ " text-align: right;\n",
473
+ " }\n",
474
+ "</style>\n",
475
+ "<table border=\"1\" class=\"dataframe\">\n",
476
+ " <thead>\n",
477
+ " <tr style=\"text-align: right;\">\n",
478
+ " <th></th>\n",
479
+ " <th>Region ID</th>\n",
480
+ " <th>Size Rank</th>\n",
481
+ " <th>Region</th>\n",
482
+ " <th>Region Type</th>\n",
483
+ " <th>StateName</th>\n",
484
+ " <th>Home Type</th>\n",
485
+ " <th>Date</th>\n",
486
+ " <th>Mean Listings Price Cut Amount (Smoothed)</th>\n",
487
+ " <th>Percent Listings Price Cut</th>\n",
488
+ " <th>Mean Listings Price Cut Amount</th>\n",
489
+ " <th>Percent Listings Price Cut (Smoothed)</th>\n",
490
+ " <th>Median Days on Pending (Smoothed)</th>\n",
491
+ " <th>Median Days on Pending</th>\n",
492
+ " </tr>\n",
493
+ " </thead>\n",
494
+ " <tbody>\n",
495
+ " <tr>\n",
496
+ " <th>0</th>\n",
497
+ " <td>102001</td>\n",
498
+ " <td>0</td>\n",
499
+ " <td>United States</td>\n",
500
+ " <td>country</td>\n",
501
+ " <td>NaN</td>\n",
502
+ " <td>SFR</td>\n",
503
+ " <td>2018-01-06</td>\n",
504
+ " <td>NaN</td>\n",
505
+ " <td>NaN</td>\n",
506
+ " <td>13508.368375</td>\n",
507
+ " <td>NaN</td>\n",
508
+ " <td>NaN</td>\n",
509
+ " <td>NaN</td>\n",
510
+ " </tr>\n",
511
+ " <tr>\n",
512
+ " <th>1</th>\n",
513
+ " <td>102001</td>\n",
514
+ " <td>0</td>\n",
515
+ " <td>United States</td>\n",
516
+ " <td>country</td>\n",
517
+ " <td>NaN</td>\n",
518
+ " <td>SFR</td>\n",
519
+ " <td>2018-01-13</td>\n",
520
+ " <td>NaN</td>\n",
521
+ " <td>0.049042</td>\n",
522
+ " <td>14114.788383</td>\n",
523
+ " <td>NaN</td>\n",
524
+ " <td>NaN</td>\n",
525
+ " <td>NaN</td>\n",
526
+ " </tr>\n",
527
+ " <tr>\n",
528
+ " <th>2</th>\n",
529
+ " <td>102001</td>\n",
530
+ " <td>0</td>\n",
531
+ " <td>United States</td>\n",
532
+ " <td>country</td>\n",
533
+ " <td>NaN</td>\n",
534
+ " <td>SFR</td>\n",
535
+ " <td>2018-01-20</td>\n",
536
+ " <td>NaN</td>\n",
537
+ " <td>0.044740</td>\n",
538
+ " <td>14326.128956</td>\n",
539
+ " <td>NaN</td>\n",
540
+ " <td>NaN</td>\n",
541
+ " <td>NaN</td>\n",
542
+ " </tr>\n",
543
+ " <tr>\n",
544
+ " <th>3</th>\n",
545
+ " <td>102001</td>\n",
546
+ " <td>0</td>\n",
547
+ " <td>United States</td>\n",
548
+ " <td>country</td>\n",
549
+ " <td>NaN</td>\n",
550
+ " <td>SFR</td>\n",
551
+ " <td>2018-01-27</td>\n",
552
+ " <td>NaN</td>\n",
553
+ " <td>0.047930</td>\n",
554
+ " <td>13998.585612</td>\n",
555
+ " <td>NaN</td>\n",
556
+ " <td>NaN</td>\n",
557
+ " <td>NaN</td>\n",
558
+ " </tr>\n",
559
+ " <tr>\n",
560
+ " <th>4</th>\n",
561
+ " <td>102001</td>\n",
562
+ " <td>0</td>\n",
563
+ " <td>United States</td>\n",
564
+ " <td>country</td>\n",
565
+ " <td>NaN</td>\n",
566
+ " <td>SFR</td>\n",
567
+ " <td>2018-02-03</td>\n",
568
+ " <td>NaN</td>\n",
569
+ " <td>0.047622</td>\n",
570
+ " <td>14120.035549</td>\n",
571
+ " <td>NaN</td>\n",
572
+ " <td>NaN</td>\n",
573
+ " <td>NaN</td>\n",
574
+ " </tr>\n",
575
+ " <tr>\n",
576
+ " <th>...</th>\n",
577
+ " <td>...</td>\n",
578
+ " <td>...</td>\n",
579
+ " <td>...</td>\n",
580
+ " <td>...</td>\n",
581
+ " <td>...</td>\n",
582
+ " <td>...</td>\n",
583
+ " <td>...</td>\n",
584
+ " <td>...</td>\n",
585
+ " <td>...</td>\n",
586
+ " <td>...</td>\n",
587
+ " <td>...</td>\n",
588
+ " <td>...</td>\n",
589
+ " <td>...</td>\n",
590
+ " </tr>\n",
591
+ " <tr>\n",
592
+ " <th>586709</th>\n",
593
+ " <td>845172</td>\n",
594
+ " <td>769</td>\n",
595
+ " <td>Winfield, KS</td>\n",
596
+ " <td>msa</td>\n",
597
+ " <td>KS</td>\n",
598
+ " <td>all homes (SFR + Condo)</td>\n",
599
+ " <td>2024-01-06</td>\n",
600
+ " <td>NaN</td>\n",
601
+ " <td>0.094017</td>\n",
602
+ " <td>NaN</td>\n",
603
+ " <td>0.037378</td>\n",
604
+ " <td>NaN</td>\n",
605
+ " <td>NaN</td>\n",
606
+ " </tr>\n",
607
+ " <tr>\n",
608
+ " <th>586710</th>\n",
609
+ " <td>845172</td>\n",
610
+ " <td>769</td>\n",
611
+ " <td>Winfield, KS</td>\n",
612
+ " <td>msa</td>\n",
613
+ " <td>KS</td>\n",
614
+ " <td>all homes (SFR + Condo)</td>\n",
615
+ " <td>2024-01-13</td>\n",
616
+ " <td>NaN</td>\n",
617
+ " <td>0.070175</td>\n",
618
+ " <td>NaN</td>\n",
619
+ " <td>0.043203</td>\n",
620
+ " <td>NaN</td>\n",
621
+ " <td>NaN</td>\n",
622
+ " </tr>\n",
623
+ " <tr>\n",
624
+ " <th>586711</th>\n",
625
+ " <td>845172</td>\n",
626
+ " <td>769</td>\n",
627
+ " <td>Winfield, KS</td>\n",
628
+ " <td>msa</td>\n",
629
+ " <td>KS</td>\n",
630
+ " <td>all homes (SFR + Condo)</td>\n",
631
+ " <td>2024-01-20</td>\n",
632
+ " <td>NaN</td>\n",
633
+ " <td>0.043478</td>\n",
634
+ " <td>NaN</td>\n",
635
+ " <td>0.054073</td>\n",
636
+ " <td>NaN</td>\n",
637
+ " <td>NaN</td>\n",
638
+ " </tr>\n",
639
+ " <tr>\n",
640
+ " <th>586712</th>\n",
641
+ " <td>845172</td>\n",
642
+ " <td>769</td>\n",
643
+ " <td>Winfield, KS</td>\n",
644
+ " <td>msa</td>\n",
645
+ " <td>KS</td>\n",
646
+ " <td>all homes (SFR + Condo)</td>\n",
647
+ " <td>2024-01-27</td>\n",
648
+ " <td>NaN</td>\n",
649
+ " <td>0.036697</td>\n",
650
+ " <td>NaN</td>\n",
651
+ " <td>0.061092</td>\n",
652
+ " <td>NaN</td>\n",
653
+ " <td>NaN</td>\n",
654
+ " </tr>\n",
655
+ " <tr>\n",
656
+ " <th>586713</th>\n",
657
+ " <td>845172</td>\n",
658
+ " <td>769</td>\n",
659
+ " <td>Winfield, KS</td>\n",
660
+ " <td>msa</td>\n",
661
+ " <td>KS</td>\n",
662
+ " <td>all homes (SFR + Condo)</td>\n",
663
+ " <td>2024-02-03</td>\n",
664
+ " <td>NaN</td>\n",
665
+ " <td>0.077670</td>\n",
666
+ " <td>NaN</td>\n",
667
+ " <td>0.057005</td>\n",
668
+ " <td>NaN</td>\n",
669
+ " <td>NaN</td>\n",
670
+ " </tr>\n",
671
+ " </tbody>\n",
672
+ "</table>\n",
673
+ "<p>586714 rows × 13 columns</p>\n",
674
+ "</div>"
675
+ ],
676
+ "text/plain": [
677
+ " Region ID Size Rank Region Region Type StateName \\\n",
678
+ "0 102001 0 United States country NaN \n",
679
+ "1 102001 0 United States country NaN \n",
680
+ "2 102001 0 United States country NaN \n",
681
+ "3 102001 0 United States country NaN \n",
682
+ "4 102001 0 United States country NaN \n",
683
+ "... ... ... ... ... ... \n",
684
+ "586709 845172 769 Winfield, KS msa KS \n",
685
+ "586710 845172 769 Winfield, KS msa KS \n",
686
+ "586711 845172 769 Winfield, KS msa KS \n",
687
+ "586712 845172 769 Winfield, KS msa KS \n",
688
+ "586713 845172 769 Winfield, KS msa KS \n",
689
+ "\n",
690
+ " Home Type Date \\\n",
691
+ "0 SFR 2018-01-06 \n",
692
+ "1 SFR 2018-01-13 \n",
693
+ "2 SFR 2018-01-20 \n",
694
+ "3 SFR 2018-01-27 \n",
695
+ "4 SFR 2018-02-03 \n",
696
+ "... ... ... \n",
697
+ "586709 all homes (SFR + Condo) 2024-01-06 \n",
698
+ "586710 all homes (SFR + Condo) 2024-01-13 \n",
699
+ "586711 all homes (SFR + Condo) 2024-01-20 \n",
700
+ "586712 all homes (SFR + Condo) 2024-01-27 \n",
701
+ "586713 all homes (SFR + Condo) 2024-02-03 \n",
702
+ "\n",
703
+ " Mean Listings Price Cut Amount (Smoothed) Percent Listings Price Cut \\\n",
704
+ "0 NaN NaN \n",
705
+ "1 NaN 0.049042 \n",
706
+ "2 NaN 0.044740 \n",
707
+ "3 NaN 0.047930 \n",
708
+ "4 NaN 0.047622 \n",
709
+ "... ... ... \n",
710
+ "586709 NaN 0.094017 \n",
711
+ "586710 NaN 0.070175 \n",
712
+ "586711 NaN 0.043478 \n",
713
+ "586712 NaN 0.036697 \n",
714
+ "586713 NaN 0.077670 \n",
715
+ "\n",
716
+ " Mean Listings Price Cut Amount Percent Listings Price Cut (Smoothed) \\\n",
717
+ "0 13508.368375 NaN \n",
718
+ "1 14114.788383 NaN \n",
719
+ "2 14326.128956 NaN \n",
720
+ "3 13998.585612 NaN \n",
721
+ "4 14120.035549 NaN \n",
722
+ "... ... ... \n",
723
+ "586709 NaN 0.037378 \n",
724
+ "586710 NaN 0.043203 \n",
725
+ "586711 NaN 0.054073 \n",
726
+ "586712 NaN 0.061092 \n",
727
+ "586713 NaN 0.057005 \n",
728
+ "\n",
729
+ " Median Days on Pending (Smoothed) Median Days on Pending \n",
730
+ "0 NaN NaN \n",
731
+ "1 NaN NaN \n",
732
+ "2 NaN NaN \n",
733
+ "3 NaN NaN \n",
734
+ "4 NaN NaN \n",
735
+ "... ... ... \n",
736
+ "586709 NaN NaN \n",
737
+ "586710 NaN NaN \n",
738
+ "586711 NaN NaN \n",
739
+ "586712 NaN NaN \n",
740
+ "586713 NaN NaN \n",
741
+ "\n",
742
+ "[586714 rows x 13 columns]"
743
+ ]
744
+ },
745
+ "execution_count": 16,
746
+ "metadata": {},
747
+ "output_type": "execute_result"
748
+ }
749
+ ],
750
+ "source": [
751
+ "final_df = combined_df\n",
752
+ "final_df = final_df.rename(\n",
753
+ " columns={\n",
754
+ " \"RegionID\": \"Region ID\",\n",
755
+ " \"SizeRank\": \"Size Rank\",\n",
756
+ " \"RegionName\": \"Region\",\n",
757
+ " \"RegionType\": \"Region Type\",\n",
758
+ " }\n",
759
+ ")\n",
760
+ "\n",
761
+ "final_df"
762
+ ]
763
+ },
764
+ {
765
+ "cell_type": "code",
766
+ "execution_count": 15,
767
+ "metadata": {},
768
+ "outputs": [],
769
+ "source": [
770
+ "if not os.path.exists(FULL_PROCESSED_DIR_PATH):\n",
771
+ " os.makedirs(FULL_PROCESSED_DIR_PATH)\n",
772
+ "\n",
773
+ "final_df.to_json(FULL_PROCESSED_DIR_PATH + \"final.jsonl\", orient=\"records\", lines=True)"
774
+ ]
775
+ }
776
+ ],
777
+ "metadata": {
778
+ "kernelspec": {
779
+ "display_name": "Python 3",
780
+ "language": "python",
781
+ "name": "python3"
782
+ },
783
+ "language_info": {
784
+ "codemirror_mode": {
785
+ "name": "ipython",
786
+ "version": 3
787
+ },
788
+ "file_extension": ".py",
789
+ "mimetype": "text/x-python",
790
+ "name": "python",
791
+ "nbconvert_exporter": "python",
792
+ "pygments_lexer": "ipython3",
793
+ "version": "3.12.2"
794
+ }
795
+ },
796
+ "nbformat": 4,
797
+ "nbformat_minor": 2
798
+ }
processors/home_values.ipynb ADDED
@@ -0,0 +1,1802 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 17,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import pandas as pd\n",
10
+ "import os"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 18,
16
+ "metadata": {},
17
+ "outputs": [],
18
+ "source": [
19
+ "DATA_DIR = \"../data\"\n",
20
+ "PROCESSED_DIR = \"../processed/\"\n",
21
+ "FACET_DIR = \"home_values/\"\n",
22
+ "FULL_DATA_DIR_PATH = os.path.join(DATA_DIR, FACET_DIR)\n",
23
+ "FULL_PROCESSED_DIR_PATH = os.path.join(PROCESSED_DIR, FACET_DIR)"
24
+ ]
25
+ },
26
+ {
27
+ "cell_type": "code",
28
+ "execution_count": 19,
29
+ "metadata": {},
30
+ "outputs": [
31
+ {
32
+ "name": "stdout",
33
+ "output_type": "stream",
34
+ "text": [
35
+ "processing City_zhvi_uc_condo_tier_0.33_0.67_sm_sa_month.csv\n",
36
+ "processing City_zhvi_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
37
+ "processing Metro_zhvi_uc_sfrcondo_tier_0.67_1.0_sm_sa_month.csv\n",
38
+ "processing County_zhvi_uc_sfrcondo_tier_0.67_1.0_sm_sa_month.csv\n",
39
+ "processing Metro_zhvi_bdrmcnt_2_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
40
+ "processing County_zhvi_bdrmcnt_4_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
41
+ "processing County_zhvi_uc_sfr_tier_0.33_0.67_sm_sa_month.csv\n",
42
+ "processing Neighborhood_zhvi_bdrmcnt_4_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
43
+ "processing State_zhvi_uc_sfr_tier_0.33_0.67_sm_sa_month.csv\n",
44
+ "processing County_zhvi_uc_condo_tier_0.33_0.67_sm_sa_month.csv\n",
45
+ "processing City_zhvi_bdrmcnt_4_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
46
+ "processing State_zhvi_bdrmcnt_5_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
47
+ "processing Zip_zhvi_bdrmcnt_2_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
48
+ "processing City_zhvi_uc_sfrcondo_tier_0.67_1.0_sm_sa_month.csv\n",
49
+ "processing Zip_zhvi_uc_condo_tier_0.33_0.67_sm_sa_month.csv\n",
50
+ "processing Neighborhood_zhvi_uc_sfr_sm_sa_month.csv\n",
51
+ "processing Metro_zhvi_uc_sfr_tier_0.33_0.67_sm_sa_month.csv\n",
52
+ "processing State_zhvi_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
53
+ "processing Zip_zhvi_bdrmcnt_1_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
54
+ "processing County_zhvi_bdrmcnt_5_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
55
+ "processing Metro_zhvi_uc_condo_tier_0.33_0.67_sm_sa_month.csv\n",
56
+ "processing Metro_zhvi_bdrmcnt_3_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
57
+ "processing Neighborhood_zhvi_bdrmcnt_5_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
58
+ "processing Zip_zhvi_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
59
+ "processing State_zhvi_uc_sfrcondo_tier_0.0_0.33_sm_sa_month.csv\n",
60
+ "processing Metro_zhvi_bdrmcnt_1_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
61
+ "processing Zip_zhvi_uc_sfr_tier_0.33_0.67_sm_sa_month.csv\n",
62
+ "processing City_zhvi_bdrmcnt_5_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
63
+ "processing State_zhvi_bdrmcnt_4_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
64
+ "processing State_zhvi_uc_condo_tier_0.33_0.67_sm_sa_month.csv\n",
65
+ "processing Zip_zhvi_bdrmcnt_3_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
66
+ "processing Neighborhood_zhvi_bdrmcnt_1_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
67
+ "processing City_zhvi_bdrmcnt_3_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
68
+ "processing County_zhvi_uc_sfr_tier_0.33_0.67_sm_sa_month (1).csv\n",
69
+ "processing County_zhvi_bdrmcnt_1_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
70
+ "processing Neighborhood_zhvi_uc_condo_tier_0.33_0.67_sm_sa_month.csv\n",
71
+ "processing Metro_zhvi_uc_sfrcondo_tier_0.33_0.67_month.csv\n",
72
+ "processing Zip_zhvi_bdrmcnt_5_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
73
+ "processing County_zhvi_uc_sfrcondo_tier_0.0_0.33_sm_sa_month.csv\n",
74
+ "processing State_zhvi_bdrmcnt_2_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
75
+ "processing Metro_zhvi_uc_sfrcondo_tier_0.0_0.33_sm_sa_month.csv\n",
76
+ "processing City_zhvi_uc_sfr_tier_0.33_0.67_sm_sa_month.csv\n",
77
+ "processing City_zhvi_bdrmcnt_1_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
78
+ "processing Neighborhood_zhvi_bdrmcnt_3_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
79
+ "processing Metro_zhvi_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
80
+ "processing Metro_zhvi_bdrmcnt_5_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
81
+ "processing County_zhvi_bdrmcnt_3_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
82
+ "processing City_zhvi_bdrmcnt_2_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
83
+ "processing Neighborhood_zhvi_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
84
+ "processing State_zhvi_uc_sfrcondo_tier_0.67_1.0_sm_sa_month.csv\n",
85
+ "processing Zip_zhvi_bdrmcnt_4_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
86
+ "processing State_zhvi_bdrmcnt_3_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
87
+ "processing State_zhvi_bdrmcnt_1_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
88
+ "processing Neighborhood_zhvi_bdrmcnt_2_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
89
+ "processing County_zhvi_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
90
+ "processing County_zhvi_bdrmcnt_2_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
91
+ "processing Metro_zhvi_bdrmcnt_4_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n",
92
+ "1\n",
93
+ "10\n",
94
+ "2\n",
95
+ "10\n",
96
+ "3\n",
97
+ "10\n",
98
+ "4\n",
99
+ "10\n",
100
+ "5\n",
101
+ "10\n",
102
+ "6\n",
103
+ "10\n",
104
+ "7\n",
105
+ "10\n",
106
+ "8\n",
107
+ "10\n",
108
+ "9\n",
109
+ "10\n"
110
+ ]
111
+ },
112
+ {
113
+ "data": {
114
+ "text/html": [
115
+ "<div>\n",
116
+ "<style scoped>\n",
117
+ " .dataframe tbody tr th:only-of-type {\n",
118
+ " vertical-align: middle;\n",
119
+ " }\n",
120
+ "\n",
121
+ " .dataframe tbody tr th {\n",
122
+ " vertical-align: top;\n",
123
+ " }\n",
124
+ "\n",
125
+ " .dataframe thead th {\n",
126
+ " text-align: right;\n",
127
+ " }\n",
128
+ "</style>\n",
129
+ "<table border=\"1\" class=\"dataframe\">\n",
130
+ " <thead>\n",
131
+ " <tr style=\"text-align: right;\">\n",
132
+ " <th></th>\n",
133
+ " <th>RegionID</th>\n",
134
+ " <th>SizeRank</th>\n",
135
+ " <th>RegionName</th>\n",
136
+ " <th>RegionType</th>\n",
137
+ " <th>StateName</th>\n",
138
+ " <th>Bedroom Count</th>\n",
139
+ " <th>Home Type</th>\n",
140
+ " <th>Date</th>\n",
141
+ " <th>Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)</th>\n",
142
+ " <th>Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)_1</th>\n",
143
+ " <th>Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)_2</th>\n",
144
+ " <th>Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted)</th>\n",
145
+ " <th>Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)_4</th>\n",
146
+ " <th>Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)_5</th>\n",
147
+ " <th>Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)_6</th>\n",
148
+ " <th>Top Tier ZHVI (Smoothed) (Seasonally Adjusted)</th>\n",
149
+ " <th>Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)_8</th>\n",
150
+ " <th>Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)_9</th>\n",
151
+ " </tr>\n",
152
+ " </thead>\n",
153
+ " <tbody>\n",
154
+ " <tr>\n",
155
+ " <th>0</th>\n",
156
+ " <td>3</td>\n",
157
+ " <td>48</td>\n",
158
+ " <td>Alaska</td>\n",
159
+ " <td>state</td>\n",
160
+ " <td>nan</td>\n",
161
+ " <td>1-Bedrooms</td>\n",
162
+ " <td>all homes (SFR/condo)</td>\n",
163
+ " <td>2000-01-31</td>\n",
164
+ " <td>NaN</td>\n",
165
+ " <td>NaN</td>\n",
166
+ " <td>NaN</td>\n",
167
+ " <td>NaN</td>\n",
168
+ " <td>NaN</td>\n",
169
+ " <td>NaN</td>\n",
170
+ " <td>NaN</td>\n",
171
+ " <td>NaN</td>\n",
172
+ " <td>NaN</td>\n",
173
+ " <td>81310.639504</td>\n",
174
+ " </tr>\n",
175
+ " <tr>\n",
176
+ " <th>1</th>\n",
177
+ " <td>3</td>\n",
178
+ " <td>48</td>\n",
179
+ " <td>Alaska</td>\n",
180
+ " <td>state</td>\n",
181
+ " <td>nan</td>\n",
182
+ " <td>1-Bedrooms</td>\n",
183
+ " <td>all homes (SFR/condo)</td>\n",
184
+ " <td>2000-02-29</td>\n",
185
+ " <td>NaN</td>\n",
186
+ " <td>NaN</td>\n",
187
+ " <td>NaN</td>\n",
188
+ " <td>NaN</td>\n",
189
+ " <td>NaN</td>\n",
190
+ " <td>NaN</td>\n",
191
+ " <td>NaN</td>\n",
192
+ " <td>NaN</td>\n",
193
+ " <td>NaN</td>\n",
194
+ " <td>80419.761984</td>\n",
195
+ " </tr>\n",
196
+ " <tr>\n",
197
+ " <th>2</th>\n",
198
+ " <td>3</td>\n",
199
+ " <td>48</td>\n",
200
+ " <td>Alaska</td>\n",
201
+ " <td>state</td>\n",
202
+ " <td>nan</td>\n",
203
+ " <td>1-Bedrooms</td>\n",
204
+ " <td>all homes (SFR/condo)</td>\n",
205
+ " <td>2000-03-31</td>\n",
206
+ " <td>NaN</td>\n",
207
+ " <td>NaN</td>\n",
208
+ " <td>NaN</td>\n",
209
+ " <td>NaN</td>\n",
210
+ " <td>NaN</td>\n",
211
+ " <td>NaN</td>\n",
212
+ " <td>NaN</td>\n",
213
+ " <td>NaN</td>\n",
214
+ " <td>NaN</td>\n",
215
+ " <td>80480.449461</td>\n",
216
+ " </tr>\n",
217
+ " <tr>\n",
218
+ " <th>3</th>\n",
219
+ " <td>3</td>\n",
220
+ " <td>48</td>\n",
221
+ " <td>Alaska</td>\n",
222
+ " <td>state</td>\n",
223
+ " <td>nan</td>\n",
224
+ " <td>1-Bedrooms</td>\n",
225
+ " <td>all homes (SFR/condo)</td>\n",
226
+ " <td>2000-04-30</td>\n",
227
+ " <td>NaN</td>\n",
228
+ " <td>NaN</td>\n",
229
+ " <td>NaN</td>\n",
230
+ " <td>NaN</td>\n",
231
+ " <td>NaN</td>\n",
232
+ " <td>NaN</td>\n",
233
+ " <td>NaN</td>\n",
234
+ " <td>NaN</td>\n",
235
+ " <td>NaN</td>\n",
236
+ " <td>79799.206525</td>\n",
237
+ " </tr>\n",
238
+ " <tr>\n",
239
+ " <th>4</th>\n",
240
+ " <td>3</td>\n",
241
+ " <td>48</td>\n",
242
+ " <td>Alaska</td>\n",
243
+ " <td>state</td>\n",
244
+ " <td>nan</td>\n",
245
+ " <td>1-Bedrooms</td>\n",
246
+ " <td>all homes (SFR/condo)</td>\n",
247
+ " <td>2000-05-31</td>\n",
248
+ " <td>NaN</td>\n",
249
+ " <td>NaN</td>\n",
250
+ " <td>NaN</td>\n",
251
+ " <td>NaN</td>\n",
252
+ " <td>NaN</td>\n",
253
+ " <td>NaN</td>\n",
254
+ " <td>NaN</td>\n",
255
+ " <td>NaN</td>\n",
256
+ " <td>NaN</td>\n",
257
+ " <td>79666.469861</td>\n",
258
+ " </tr>\n",
259
+ " <tr>\n",
260
+ " <th>...</th>\n",
261
+ " <td>...</td>\n",
262
+ " <td>...</td>\n",
263
+ " <td>...</td>\n",
264
+ " <td>...</td>\n",
265
+ " <td>...</td>\n",
266
+ " <td>...</td>\n",
267
+ " <td>...</td>\n",
268
+ " <td>...</td>\n",
269
+ " <td>...</td>\n",
270
+ " <td>...</td>\n",
271
+ " <td>...</td>\n",
272
+ " <td>...</td>\n",
273
+ " <td>...</td>\n",
274
+ " <td>...</td>\n",
275
+ " <td>...</td>\n",
276
+ " <td>...</td>\n",
277
+ " <td>...</td>\n",
278
+ " <td>...</td>\n",
279
+ " </tr>\n",
280
+ " <tr>\n",
281
+ " <th>117907</th>\n",
282
+ " <td>62</td>\n",
283
+ " <td>51</td>\n",
284
+ " <td>Wyoming</td>\n",
285
+ " <td>state</td>\n",
286
+ " <td>nan</td>\n",
287
+ " <td>All Bedrooms</td>\n",
288
+ " <td>condo</td>\n",
289
+ " <td>2023-09-30</td>\n",
290
+ " <td>NaN</td>\n",
291
+ " <td>NaN</td>\n",
292
+ " <td>NaN</td>\n",
293
+ " <td>NaN</td>\n",
294
+ " <td>NaN</td>\n",
295
+ " <td>486974.735908</td>\n",
296
+ " <td>NaN</td>\n",
297
+ " <td>NaN</td>\n",
298
+ " <td>NaN</td>\n",
299
+ " <td>NaN</td>\n",
300
+ " </tr>\n",
301
+ " <tr>\n",
302
+ " <th>117908</th>\n",
303
+ " <td>62</td>\n",
304
+ " <td>51</td>\n",
305
+ " <td>Wyoming</td>\n",
306
+ " <td>state</td>\n",
307
+ " <td>nan</td>\n",
308
+ " <td>All Bedrooms</td>\n",
309
+ " <td>condo</td>\n",
310
+ " <td>2023-10-31</td>\n",
311
+ " <td>NaN</td>\n",
312
+ " <td>NaN</td>\n",
313
+ " <td>NaN</td>\n",
314
+ " <td>NaN</td>\n",
315
+ " <td>NaN</td>\n",
316
+ " <td>485847.539614</td>\n",
317
+ " <td>NaN</td>\n",
318
+ " <td>NaN</td>\n",
319
+ " <td>NaN</td>\n",
320
+ " <td>NaN</td>\n",
321
+ " </tr>\n",
322
+ " <tr>\n",
323
+ " <th>117909</th>\n",
324
+ " <td>62</td>\n",
325
+ " <td>51</td>\n",
326
+ " <td>Wyoming</td>\n",
327
+ " <td>state</td>\n",
328
+ " <td>nan</td>\n",
329
+ " <td>All Bedrooms</td>\n",
330
+ " <td>condo</td>\n",
331
+ " <td>2023-11-30</td>\n",
332
+ " <td>NaN</td>\n",
333
+ " <td>NaN</td>\n",
334
+ " <td>NaN</td>\n",
335
+ " <td>NaN</td>\n",
336
+ " <td>NaN</td>\n",
337
+ " <td>484223.885775</td>\n",
338
+ " <td>NaN</td>\n",
339
+ " <td>NaN</td>\n",
340
+ " <td>NaN</td>\n",
341
+ " <td>NaN</td>\n",
342
+ " </tr>\n",
343
+ " <tr>\n",
344
+ " <th>117910</th>\n",
345
+ " <td>62</td>\n",
346
+ " <td>51</td>\n",
347
+ " <td>Wyoming</td>\n",
348
+ " <td>state</td>\n",
349
+ " <td>nan</td>\n",
350
+ " <td>All Bedrooms</td>\n",
351
+ " <td>condo</td>\n",
352
+ " <td>2023-12-31</td>\n",
353
+ " <td>NaN</td>\n",
354
+ " <td>NaN</td>\n",
355
+ " <td>NaN</td>\n",
356
+ " <td>NaN</td>\n",
357
+ " <td>NaN</td>\n",
358
+ " <td>481522.403338</td>\n",
359
+ " <td>NaN</td>\n",
360
+ " <td>NaN</td>\n",
361
+ " <td>NaN</td>\n",
362
+ " <td>NaN</td>\n",
363
+ " </tr>\n",
364
+ " <tr>\n",
365
+ " <th>117911</th>\n",
366
+ " <td>62</td>\n",
367
+ " <td>51</td>\n",
368
+ " <td>Wyoming</td>\n",
369
+ " <td>state</td>\n",
370
+ " <td>nan</td>\n",
371
+ " <td>All Bedrooms</td>\n",
372
+ " <td>condo</td>\n",
373
+ " <td>2024-01-31</td>\n",
374
+ " <td>NaN</td>\n",
375
+ " <td>NaN</td>\n",
376
+ " <td>NaN</td>\n",
377
+ " <td>NaN</td>\n",
378
+ " <td>NaN</td>\n",
379
+ " <td>481181.718200</td>\n",
380
+ " <td>NaN</td>\n",
381
+ " <td>NaN</td>\n",
382
+ " <td>NaN</td>\n",
383
+ " <td>NaN</td>\n",
384
+ " </tr>\n",
385
+ " </tbody>\n",
386
+ "</table>\n",
387
+ "<p>117912 rows × 18 columns</p>\n",
388
+ "</div>"
389
+ ],
390
+ "text/plain": [
391
+ " RegionID SizeRank RegionName RegionType StateName Bedroom Count \\\n",
392
+ "0 3 48 Alaska state nan 1-Bedrooms \n",
393
+ "1 3 48 Alaska state nan 1-Bedrooms \n",
394
+ "2 3 48 Alaska state nan 1-Bedrooms \n",
395
+ "3 3 48 Alaska state nan 1-Bedrooms \n",
396
+ "4 3 48 Alaska state nan 1-Bedrooms \n",
397
+ "... ... ... ... ... ... ... \n",
398
+ "117907 62 51 Wyoming state nan All Bedrooms \n",
399
+ "117908 62 51 Wyoming state nan All Bedrooms \n",
400
+ "117909 62 51 Wyoming state nan All Bedrooms \n",
401
+ "117910 62 51 Wyoming state nan All Bedrooms \n",
402
+ "117911 62 51 Wyoming state nan All Bedrooms \n",
403
+ "\n",
404
+ " Home Type Date \\\n",
405
+ "0 all homes (SFR/condo) 2000-01-31 \n",
406
+ "1 all homes (SFR/condo) 2000-02-29 \n",
407
+ "2 all homes (SFR/condo) 2000-03-31 \n",
408
+ "3 all homes (SFR/condo) 2000-04-30 \n",
409
+ "4 all homes (SFR/condo) 2000-05-31 \n",
410
+ "... ... ... \n",
411
+ "117907 condo 2023-09-30 \n",
412
+ "117908 condo 2023-10-31 \n",
413
+ "117909 condo 2023-11-30 \n",
414
+ "117910 condo 2023-12-31 \n",
415
+ "117911 condo 2024-01-31 \n",
416
+ "\n",
417
+ " Mid Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n",
418
+ "0 NaN \n",
419
+ "1 NaN \n",
420
+ "2 NaN \n",
421
+ "3 NaN \n",
422
+ "4 NaN \n",
423
+ "... ... \n",
424
+ "117907 NaN \n",
425
+ "117908 NaN \n",
426
+ "117909 NaN \n",
427
+ "117910 NaN \n",
428
+ "117911 NaN \n",
429
+ "\n",
430
+ " Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)_1 \\\n",
431
+ "0 NaN \n",
432
+ "1 NaN \n",
433
+ "2 NaN \n",
434
+ "3 NaN \n",
435
+ "4 NaN \n",
436
+ "... ... \n",
437
+ "117907 NaN \n",
438
+ "117908 NaN \n",
439
+ "117909 NaN \n",
440
+ "117910 NaN \n",
441
+ "117911 NaN \n",
442
+ "\n",
443
+ " Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)_2 \\\n",
444
+ "0 NaN \n",
445
+ "1 NaN \n",
446
+ "2 NaN \n",
447
+ "3 NaN \n",
448
+ "4 NaN \n",
449
+ "... ... \n",
450
+ "117907 NaN \n",
451
+ "117908 NaN \n",
452
+ "117909 NaN \n",
453
+ "117910 NaN \n",
454
+ "117911 NaN \n",
455
+ "\n",
456
+ " Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n",
457
+ "0 NaN \n",
458
+ "1 NaN \n",
459
+ "2 NaN \n",
460
+ "3 NaN \n",
461
+ "4 NaN \n",
462
+ "... ... \n",
463
+ "117907 NaN \n",
464
+ "117908 NaN \n",
465
+ "117909 NaN \n",
466
+ "117910 NaN \n",
467
+ "117911 NaN \n",
468
+ "\n",
469
+ " Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)_4 \\\n",
470
+ "0 NaN \n",
471
+ "1 NaN \n",
472
+ "2 NaN \n",
473
+ "3 NaN \n",
474
+ "4 NaN \n",
475
+ "... ... \n",
476
+ "117907 NaN \n",
477
+ "117908 NaN \n",
478
+ "117909 NaN \n",
479
+ "117910 NaN \n",
480
+ "117911 NaN \n",
481
+ "\n",
482
+ " Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)_5 \\\n",
483
+ "0 NaN \n",
484
+ "1 NaN \n",
485
+ "2 NaN \n",
486
+ "3 NaN \n",
487
+ "4 NaN \n",
488
+ "... ... \n",
489
+ "117907 486974.735908 \n",
490
+ "117908 485847.539614 \n",
491
+ "117909 484223.885775 \n",
492
+ "117910 481522.403338 \n",
493
+ "117911 481181.718200 \n",
494
+ "\n",
495
+ " Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)_6 \\\n",
496
+ "0 NaN \n",
497
+ "1 NaN \n",
498
+ "2 NaN \n",
499
+ "3 NaN \n",
500
+ "4 NaN \n",
501
+ "... ... \n",
502
+ "117907 NaN \n",
503
+ "117908 NaN \n",
504
+ "117909 NaN \n",
505
+ "117910 NaN \n",
506
+ "117911 NaN \n",
507
+ "\n",
508
+ " Top Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n",
509
+ "0 NaN \n",
510
+ "1 NaN \n",
511
+ "2 NaN \n",
512
+ "3 NaN \n",
513
+ "4 NaN \n",
514
+ "... ... \n",
515
+ "117907 NaN \n",
516
+ "117908 NaN \n",
517
+ "117909 NaN \n",
518
+ "117910 NaN \n",
519
+ "117911 NaN \n",
520
+ "\n",
521
+ " Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)_8 \\\n",
522
+ "0 NaN \n",
523
+ "1 NaN \n",
524
+ "2 NaN \n",
525
+ "3 NaN \n",
526
+ "4 NaN \n",
527
+ "... ... \n",
528
+ "117907 NaN \n",
529
+ "117908 NaN \n",
530
+ "117909 NaN \n",
531
+ "117910 NaN \n",
532
+ "117911 NaN \n",
533
+ "\n",
534
+ " Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)_9 \n",
535
+ "0 81310.639504 \n",
536
+ "1 80419.761984 \n",
537
+ "2 80480.449461 \n",
538
+ "3 79799.206525 \n",
539
+ "4 79666.469861 \n",
540
+ "... ... \n",
541
+ "117907 NaN \n",
542
+ "117908 NaN \n",
543
+ "117909 NaN \n",
544
+ "117910 NaN \n",
545
+ "117911 NaN \n",
546
+ "\n",
547
+ "[117912 rows x 18 columns]"
548
+ ]
549
+ },
550
+ "execution_count": 19,
551
+ "metadata": {},
552
+ "output_type": "execute_result"
553
+ }
554
+ ],
555
+ "source": [
556
+ "# base cols RegionID,SizeRank,RegionName,RegionType,StateName\n",
557
+ "\n",
558
+ "data_frames = []\n",
559
+ "\n",
560
+ "for filename in os.listdir(FULL_DATA_DIR_PATH):\n",
561
+ " if filename.endswith(\".csv\"):\n",
562
+ " print(\"processing \" + filename)\n",
563
+ " cur_df = pd.read_csv(os.path.join(FULL_DATA_DIR_PATH, filename))\n",
564
+ " exclude_columns = [\n",
565
+ " \"RegionID\",\n",
566
+ " \"SizeRank\",\n",
567
+ " \"RegionName\",\n",
568
+ " \"RegionType\",\n",
569
+ " \"StateName\",\n",
570
+ " \"Bedroom Count\",\n",
571
+ " \"Home Type\",\n",
572
+ " ]\n",
573
+ "\n",
574
+ " if \"Zip\" in filename:\n",
575
+ " continue\n",
576
+ " if \"Neighborhood\" in filename:\n",
577
+ " continue\n",
578
+ " if \"City\" in filename:\n",
579
+ " continue\n",
580
+ " if \"Metro\" in filename:\n",
581
+ " continue\n",
582
+ " if \"County\" in filename:\n",
583
+ " continue\n",
584
+ "\n",
585
+ " if \"City\" in filename:\n",
586
+ " exclude_columns = [\n",
587
+ " \"RegionID\",\n",
588
+ " \"SizeRank\",\n",
589
+ " \"RegionName\",\n",
590
+ " \"RegionType\",\n",
591
+ " \"StateName\",\n",
592
+ " \"Bedroom Count\",\n",
593
+ " \"Home Type\",\n",
594
+ " # City Specific\n",
595
+ " \"State\",\n",
596
+ " \"Metro\",\n",
597
+ " \"CountyName\",\n",
598
+ " ]\n",
599
+ " elif \"Zip\" in filename:\n",
600
+ " exclude_columns = [\n",
601
+ " \"RegionID\",\n",
602
+ " \"SizeRank\",\n",
603
+ " \"RegionName\",\n",
604
+ " \"RegionType\",\n",
605
+ " \"StateName\",\n",
606
+ " \"Bedroom Count\",\n",
607
+ " \"Home Type\",\n",
608
+ " # Zip Specific\n",
609
+ " \"State\",\n",
610
+ " \"City\",\n",
611
+ " \"Metro\",\n",
612
+ " \"CountyName\",\n",
613
+ " ]\n",
614
+ " elif \"County\" in filename:\n",
615
+ " exclude_columns = [\n",
616
+ " \"RegionID\",\n",
617
+ " \"SizeRank\",\n",
618
+ " \"RegionName\",\n",
619
+ " \"RegionType\",\n",
620
+ " \"StateName\",\n",
621
+ " \"Bedroom Count\",\n",
622
+ " \"Home Type\",\n",
623
+ " # County Specific\n",
624
+ " \"State\",\n",
625
+ " \"Metro\",\n",
626
+ " \"StateCodeFIPS\",\n",
627
+ " \"MunicipalCodeFIPS\",\n",
628
+ " ]\n",
629
+ " elif \"Neighborhood\" in filename:\n",
630
+ " exclude_columns = [\n",
631
+ " \"RegionID\",\n",
632
+ " \"SizeRank\",\n",
633
+ " \"RegionName\",\n",
634
+ " \"RegionType\",\n",
635
+ " \"StateName\",\n",
636
+ " \"Bedroom Count\",\n",
637
+ " \"Home Type\",\n",
638
+ " # Neighborhood Specific\n",
639
+ " \"State\",\n",
640
+ " \"City\",\n",
641
+ " \"Metro\",\n",
642
+ " \"CountyName\",\n",
643
+ " ]\n",
644
+ "\n",
645
+ " if \"_bdrmcnt_1_\" in filename:\n",
646
+ " cur_df[\"Bedroom Count\"] = \"1-Bedrooms\"\n",
647
+ " elif \"_bdrmcnt_2_\" in filename:\n",
648
+ " cur_df[\"Bedroom Count\"] = \"2-Bedrooms\"\n",
649
+ " elif \"_bdrmcnt_3_\" in filename:\n",
650
+ " cur_df[\"Bedroom Count\"] = \"3-Bedrooms\"\n",
651
+ " elif \"_bdrmcnt_4_\" in filename:\n",
652
+ " cur_df[\"Bedroom Count\"] = \"4 Bedrooms\"\n",
653
+ " elif \"_bdrmcnt_5_\" in filename:\n",
654
+ " cur_df[\"Bedroom Count\"] = \"5+ Bedrooms\"\n",
655
+ " else:\n",
656
+ " cur_df[\"Bedroom Count\"] = \"All Bedrooms\"\n",
657
+ "\n",
658
+ " if \"_uc_sfr_\" in filename:\n",
659
+ " cur_df[\"Home Type\"] = \"SFR\"\n",
660
+ " elif \"_uc_sfrcondo_\" in filename:\n",
661
+ " cur_df[\"Home Type\"] = \"all homes (SFR/condo)\"\n",
662
+ " elif \"_uc_condo_\" in filename:\n",
663
+ " cur_df[\"Home Type\"] = \"condo\"\n",
664
+ "\n",
665
+ " # Identify columns to pivot\n",
666
+ " columns_to_pivot = [col for col in cur_df.columns if col not in exclude_columns]\n",
667
+ "\n",
668
+ " smoothed = \"_sm_\" in filename\n",
669
+ " seasonally_adjusted = \"_sa_\" in filename\n",
670
+ "\n",
671
+ " if \"_tier_0.33_0.67_\" in filename:\n",
672
+ " col_name = \"Mid Tier ZHVI\"\n",
673
+ " if smoothed:\n",
674
+ " col_name += \" (Smoothed)\"\n",
675
+ " if seasonally_adjusted:\n",
676
+ " col_name += \" (Seasonally Adjusted)\"\n",
677
+ "\n",
678
+ " cur_df = pd.melt(\n",
679
+ " cur_df,\n",
680
+ " id_vars=exclude_columns,\n",
681
+ " value_vars=columns_to_pivot,\n",
682
+ " var_name=\"Date\",\n",
683
+ " value_name=col_name,\n",
684
+ " )\n",
685
+ " elif \"_tier_0.0_0.33_\" in filename:\n",
686
+ " col_name = \"Bottom Tier ZHVI\"\n",
687
+ " if smoothed:\n",
688
+ " col_name += \" (Smoothed)\"\n",
689
+ " if seasonally_adjusted:\n",
690
+ " col_name += \" (Seasonally Adjusted)\"\n",
691
+ "\n",
692
+ " cur_df = pd.melt(\n",
693
+ " cur_df,\n",
694
+ " id_vars=exclude_columns,\n",
695
+ " value_vars=columns_to_pivot,\n",
696
+ " var_name=\"Date\",\n",
697
+ " value_name=col_name,\n",
698
+ " )\n",
699
+ " elif \"_tier_0.67_1.0_\" in filename:\n",
700
+ " col_name = \"Top Tier ZHVI\"\n",
701
+ " if smoothed:\n",
702
+ " col_name += \" (Smoothed)\"\n",
703
+ " if seasonally_adjusted:\n",
704
+ " col_name += \" (Seasonally Adjusted)\"\n",
705
+ "\n",
706
+ " cur_df = pd.melt(\n",
707
+ " cur_df,\n",
708
+ " id_vars=exclude_columns,\n",
709
+ " value_vars=columns_to_pivot,\n",
710
+ " var_name=\"Date\",\n",
711
+ " value_name=col_name,\n",
712
+ " )\n",
713
+ " else:\n",
714
+ " col_name = \"ZHVI\"\n",
715
+ " if smoothed:\n",
716
+ " col_name += \" (Smoothed)\"\n",
717
+ " if seasonally_adjusted:\n",
718
+ " col_name += \" (Seasonally Adjusted)\"\n",
719
+ "\n",
720
+ " cur_df = pd.melt(\n",
721
+ " cur_df,\n",
722
+ " id_vars=exclude_columns,\n",
723
+ " value_vars=columns_to_pivot,\n",
724
+ " var_name=\"Date\",\n",
725
+ " value_name=col_name,\n",
726
+ " )\n",
727
+ "\n",
728
+ " cur_df[\"StateName\"] = cur_df[\"StateName\"].astype(str)\n",
729
+ " cur_df[\"RegionName\"] = cur_df[\"RegionName\"].astype(str)\n",
730
+ "\n",
731
+ " data_frames.append(cur_df)\n",
732
+ "\n",
733
+ "\n",
734
+ "def get_combined_df(data_frames):\n",
735
+ " combined_df = None\n",
736
+ " if len(data_frames) > 1:\n",
737
+ " # iterate over dataframes and merge or concat\n",
738
+ " combined_df = data_frames[0]\n",
739
+ " for i in range(1, len(data_frames)):\n",
740
+ " print(i)\n",
741
+ " print(len(data_frames))\n",
742
+ " cur_df = data_frames[i]\n",
743
+ " combined_df = pd.merge(\n",
744
+ " combined_df,\n",
745
+ " cur_df,\n",
746
+ " on=[\n",
747
+ " \"RegionID\",\n",
748
+ " \"SizeRank\",\n",
749
+ " \"RegionName\",\n",
750
+ " \"RegionType\",\n",
751
+ " \"StateName\",\n",
752
+ " \"Bedroom Count\",\n",
753
+ " \"Home Type\",\n",
754
+ " \"Date\",\n",
755
+ " ],\n",
756
+ " how=\"outer\",\n",
757
+ " suffixes=(\"\", \"_\" + str(i)),\n",
758
+ " )\n",
759
+ " elif len(data_frames) == 1:\n",
760
+ " combined_df = data_frames[0]\n",
761
+ "\n",
762
+ " return combined_df\n",
763
+ "\n",
764
+ "\n",
765
+ "combined_df = get_combined_df(data_frames)\n",
766
+ "combined_df"
767
+ ]
768
+ },
769
+ {
770
+ "cell_type": "code",
771
+ "execution_count": 20,
772
+ "metadata": {},
773
+ "outputs": [
774
+ {
775
+ "name": "stdout",
776
+ "output_type": "stream",
777
+ "text": [
778
+ "ZHVI\n",
779
+ "Mid Tier ZHVI\n",
780
+ "Bottom Tier ZHVI\n",
781
+ "Top Tier ZHVI\n"
782
+ ]
783
+ },
784
+ {
785
+ "data": {
786
+ "text/html": [
787
+ "<div>\n",
788
+ "<style scoped>\n",
789
+ " .dataframe tbody tr th:only-of-type {\n",
790
+ " vertical-align: middle;\n",
791
+ " }\n",
792
+ "\n",
793
+ " .dataframe tbody tr th {\n",
794
+ " vertical-align: top;\n",
795
+ " }\n",
796
+ "\n",
797
+ " .dataframe thead th {\n",
798
+ " text-align: right;\n",
799
+ " }\n",
800
+ "</style>\n",
801
+ "<table border=\"1\" class=\"dataframe\">\n",
802
+ " <thead>\n",
803
+ " <tr style=\"text-align: right;\">\n",
804
+ " <th></th>\n",
805
+ " <th>RegionID</th>\n",
806
+ " <th>SizeRank</th>\n",
807
+ " <th>RegionName</th>\n",
808
+ " <th>RegionType</th>\n",
809
+ " <th>StateName</th>\n",
810
+ " <th>Bedroom Count</th>\n",
811
+ " <th>Home Type</th>\n",
812
+ " <th>Date</th>\n",
813
+ " <th>Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)</th>\n",
814
+ " <th>Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted)</th>\n",
815
+ " <th>Top Tier ZHVI (Smoothed) (Seasonally Adjusted)</th>\n",
816
+ " <th>ZHVI</th>\n",
817
+ " <th>Mid Tier ZHVI</th>\n",
818
+ " </tr>\n",
819
+ " </thead>\n",
820
+ " <tbody>\n",
821
+ " <tr>\n",
822
+ " <th>0</th>\n",
823
+ " <td>3</td>\n",
824
+ " <td>48</td>\n",
825
+ " <td>Alaska</td>\n",
826
+ " <td>state</td>\n",
827
+ " <td>nan</td>\n",
828
+ " <td>1-Bedrooms</td>\n",
829
+ " <td>all homes (SFR/condo)</td>\n",
830
+ " <td>2000-01-31</td>\n",
831
+ " <td>NaN</td>\n",
832
+ " <td>NaN</td>\n",
833
+ " <td>NaN</td>\n",
834
+ " <td>81310.639504</td>\n",
835
+ " <td>81310.639504</td>\n",
836
+ " </tr>\n",
837
+ " <tr>\n",
838
+ " <th>1</th>\n",
839
+ " <td>3</td>\n",
840
+ " <td>48</td>\n",
841
+ " <td>Alaska</td>\n",
842
+ " <td>state</td>\n",
843
+ " <td>nan</td>\n",
844
+ " <td>1-Bedrooms</td>\n",
845
+ " <td>all homes (SFR/condo)</td>\n",
846
+ " <td>2000-02-29</td>\n",
847
+ " <td>NaN</td>\n",
848
+ " <td>NaN</td>\n",
849
+ " <td>NaN</td>\n",
850
+ " <td>80419.761984</td>\n",
851
+ " <td>80419.761984</td>\n",
852
+ " </tr>\n",
853
+ " <tr>\n",
854
+ " <th>2</th>\n",
855
+ " <td>3</td>\n",
856
+ " <td>48</td>\n",
857
+ " <td>Alaska</td>\n",
858
+ " <td>state</td>\n",
859
+ " <td>nan</td>\n",
860
+ " <td>1-Bedrooms</td>\n",
861
+ " <td>all homes (SFR/condo)</td>\n",
862
+ " <td>2000-03-31</td>\n",
863
+ " <td>NaN</td>\n",
864
+ " <td>NaN</td>\n",
865
+ " <td>NaN</td>\n",
866
+ " <td>80480.449461</td>\n",
867
+ " <td>80480.449461</td>\n",
868
+ " </tr>\n",
869
+ " <tr>\n",
870
+ " <th>3</th>\n",
871
+ " <td>3</td>\n",
872
+ " <td>48</td>\n",
873
+ " <td>Alaska</td>\n",
874
+ " <td>state</td>\n",
875
+ " <td>nan</td>\n",
876
+ " <td>1-Bedrooms</td>\n",
877
+ " <td>all homes (SFR/condo)</td>\n",
878
+ " <td>2000-04-30</td>\n",
879
+ " <td>NaN</td>\n",
880
+ " <td>NaN</td>\n",
881
+ " <td>NaN</td>\n",
882
+ " <td>79799.206525</td>\n",
883
+ " <td>79799.206525</td>\n",
884
+ " </tr>\n",
885
+ " <tr>\n",
886
+ " <th>4</th>\n",
887
+ " <td>3</td>\n",
888
+ " <td>48</td>\n",
889
+ " <td>Alaska</td>\n",
890
+ " <td>state</td>\n",
891
+ " <td>nan</td>\n",
892
+ " <td>1-Bedrooms</td>\n",
893
+ " <td>all homes (SFR/condo)</td>\n",
894
+ " <td>2000-05-31</td>\n",
895
+ " <td>NaN</td>\n",
896
+ " <td>NaN</td>\n",
897
+ " <td>NaN</td>\n",
898
+ " <td>79666.469861</td>\n",
899
+ " <td>79666.469861</td>\n",
900
+ " </tr>\n",
901
+ " <tr>\n",
902
+ " <th>...</th>\n",
903
+ " <td>...</td>\n",
904
+ " <td>...</td>\n",
905
+ " <td>...</td>\n",
906
+ " <td>...</td>\n",
907
+ " <td>...</td>\n",
908
+ " <td>...</td>\n",
909
+ " <td>...</td>\n",
910
+ " <td>...</td>\n",
911
+ " <td>...</td>\n",
912
+ " <td>...</td>\n",
913
+ " <td>...</td>\n",
914
+ " <td>...</td>\n",
915
+ " <td>...</td>\n",
916
+ " </tr>\n",
917
+ " <tr>\n",
918
+ " <th>117907</th>\n",
919
+ " <td>62</td>\n",
920
+ " <td>51</td>\n",
921
+ " <td>Wyoming</td>\n",
922
+ " <td>state</td>\n",
923
+ " <td>nan</td>\n",
924
+ " <td>All Bedrooms</td>\n",
925
+ " <td>condo</td>\n",
926
+ " <td>2023-09-30</td>\n",
927
+ " <td>NaN</td>\n",
928
+ " <td>NaN</td>\n",
929
+ " <td>NaN</td>\n",
930
+ " <td>486974.735908</td>\n",
931
+ " <td>486974.735908</td>\n",
932
+ " </tr>\n",
933
+ " <tr>\n",
934
+ " <th>117908</th>\n",
935
+ " <td>62</td>\n",
936
+ " <td>51</td>\n",
937
+ " <td>Wyoming</td>\n",
938
+ " <td>state</td>\n",
939
+ " <td>nan</td>\n",
940
+ " <td>All Bedrooms</td>\n",
941
+ " <td>condo</td>\n",
942
+ " <td>2023-10-31</td>\n",
943
+ " <td>NaN</td>\n",
944
+ " <td>NaN</td>\n",
945
+ " <td>NaN</td>\n",
946
+ " <td>485847.539614</td>\n",
947
+ " <td>485847.539614</td>\n",
948
+ " </tr>\n",
949
+ " <tr>\n",
950
+ " <th>117909</th>\n",
951
+ " <td>62</td>\n",
952
+ " <td>51</td>\n",
953
+ " <td>Wyoming</td>\n",
954
+ " <td>state</td>\n",
955
+ " <td>nan</td>\n",
956
+ " <td>All Bedrooms</td>\n",
957
+ " <td>condo</td>\n",
958
+ " <td>2023-11-30</td>\n",
959
+ " <td>NaN</td>\n",
960
+ " <td>NaN</td>\n",
961
+ " <td>NaN</td>\n",
962
+ " <td>484223.885775</td>\n",
963
+ " <td>484223.885775</td>\n",
964
+ " </tr>\n",
965
+ " <tr>\n",
966
+ " <th>117910</th>\n",
967
+ " <td>62</td>\n",
968
+ " <td>51</td>\n",
969
+ " <td>Wyoming</td>\n",
970
+ " <td>state</td>\n",
971
+ " <td>nan</td>\n",
972
+ " <td>All Bedrooms</td>\n",
973
+ " <td>condo</td>\n",
974
+ " <td>2023-12-31</td>\n",
975
+ " <td>NaN</td>\n",
976
+ " <td>NaN</td>\n",
977
+ " <td>NaN</td>\n",
978
+ " <td>481522.403338</td>\n",
979
+ " <td>481522.403338</td>\n",
980
+ " </tr>\n",
981
+ " <tr>\n",
982
+ " <th>117911</th>\n",
983
+ " <td>62</td>\n",
984
+ " <td>51</td>\n",
985
+ " <td>Wyoming</td>\n",
986
+ " <td>state</td>\n",
987
+ " <td>nan</td>\n",
988
+ " <td>All Bedrooms</td>\n",
989
+ " <td>condo</td>\n",
990
+ " <td>2024-01-31</td>\n",
991
+ " <td>NaN</td>\n",
992
+ " <td>NaN</td>\n",
993
+ " <td>NaN</td>\n",
994
+ " <td>481181.718200</td>\n",
995
+ " <td>481181.718200</td>\n",
996
+ " </tr>\n",
997
+ " </tbody>\n",
998
+ "</table>\n",
999
+ "<p>117912 rows × 13 columns</p>\n",
1000
+ "</div>"
1001
+ ],
1002
+ "text/plain": [
1003
+ " RegionID SizeRank RegionName RegionType StateName Bedroom Count \\\n",
1004
+ "0 3 48 Alaska state nan 1-Bedrooms \n",
1005
+ "1 3 48 Alaska state nan 1-Bedrooms \n",
1006
+ "2 3 48 Alaska state nan 1-Bedrooms \n",
1007
+ "3 3 48 Alaska state nan 1-Bedrooms \n",
1008
+ "4 3 48 Alaska state nan 1-Bedrooms \n",
1009
+ "... ... ... ... ... ... ... \n",
1010
+ "117907 62 51 Wyoming state nan All Bedrooms \n",
1011
+ "117908 62 51 Wyoming state nan All Bedrooms \n",
1012
+ "117909 62 51 Wyoming state nan All Bedrooms \n",
1013
+ "117910 62 51 Wyoming state nan All Bedrooms \n",
1014
+ "117911 62 51 Wyoming state nan All Bedrooms \n",
1015
+ "\n",
1016
+ " Home Type Date \\\n",
1017
+ "0 all homes (SFR/condo) 2000-01-31 \n",
1018
+ "1 all homes (SFR/condo) 2000-02-29 \n",
1019
+ "2 all homes (SFR/condo) 2000-03-31 \n",
1020
+ "3 all homes (SFR/condo) 2000-04-30 \n",
1021
+ "4 all homes (SFR/condo) 2000-05-31 \n",
1022
+ "... ... ... \n",
1023
+ "117907 condo 2023-09-30 \n",
1024
+ "117908 condo 2023-10-31 \n",
1025
+ "117909 condo 2023-11-30 \n",
1026
+ "117910 condo 2023-12-31 \n",
1027
+ "117911 condo 2024-01-31 \n",
1028
+ "\n",
1029
+ " Mid Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n",
1030
+ "0 NaN \n",
1031
+ "1 NaN \n",
1032
+ "2 NaN \n",
1033
+ "3 NaN \n",
1034
+ "4 NaN \n",
1035
+ "... ... \n",
1036
+ "117907 NaN \n",
1037
+ "117908 NaN \n",
1038
+ "117909 NaN \n",
1039
+ "117910 NaN \n",
1040
+ "117911 NaN \n",
1041
+ "\n",
1042
+ " Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n",
1043
+ "0 NaN \n",
1044
+ "1 NaN \n",
1045
+ "2 NaN \n",
1046
+ "3 NaN \n",
1047
+ "4 NaN \n",
1048
+ "... ... \n",
1049
+ "117907 NaN \n",
1050
+ "117908 NaN \n",
1051
+ "117909 NaN \n",
1052
+ "117910 NaN \n",
1053
+ "117911 NaN \n",
1054
+ "\n",
1055
+ " Top Tier ZHVI (Smoothed) (Seasonally Adjusted) ZHVI \\\n",
1056
+ "0 NaN 81310.639504 \n",
1057
+ "1 NaN 80419.761984 \n",
1058
+ "2 NaN 80480.449461 \n",
1059
+ "3 NaN 79799.206525 \n",
1060
+ "4 NaN 79666.469861 \n",
1061
+ "... ... ... \n",
1062
+ "117907 NaN 486974.735908 \n",
1063
+ "117908 NaN 485847.539614 \n",
1064
+ "117909 NaN 484223.885775 \n",
1065
+ "117910 NaN 481522.403338 \n",
1066
+ "117911 NaN 481181.718200 \n",
1067
+ "\n",
1068
+ " Mid Tier ZHVI \n",
1069
+ "0 81310.639504 \n",
1070
+ "1 80419.761984 \n",
1071
+ "2 80480.449461 \n",
1072
+ "3 79799.206525 \n",
1073
+ "4 79666.469861 \n",
1074
+ "... ... \n",
1075
+ "117907 486974.735908 \n",
1076
+ "117908 485847.539614 \n",
1077
+ "117909 484223.885775 \n",
1078
+ "117910 481522.403338 \n",
1079
+ "117911 481181.718200 \n",
1080
+ "\n",
1081
+ "[117912 rows x 13 columns]"
1082
+ ]
1083
+ },
1084
+ "execution_count": 20,
1085
+ "metadata": {},
1086
+ "output_type": "execute_result"
1087
+ }
1088
+ ],
1089
+ "source": [
1090
+ "# iterate over rows of combined df and coalesce column values across columns that start with \"Median Sale Price\"\n",
1091
+ "columns_to_coalesce = [\"ZHVI\", \"Mid Tier ZHVI\", \"Bottom Tier ZHVI\", \"Top Tier ZHVI\"]\n",
1092
+ "\n",
1093
+ "for column_to_coalesce in columns_to_coalesce:\n",
1094
+ " print(column_to_coalesce)\n",
1095
+ " for index, row in combined_df.iterrows():\n",
1096
+ " for col in combined_df.columns:\n",
1097
+ " if column_to_coalesce in col and \"_\" in col:\n",
1098
+ " if not pd.isna(row[col]):\n",
1099
+ " combined_df.at[index, column_to_coalesce] = row[col]\n",
1100
+ "\n",
1101
+ "# remove columns with underscores\n",
1102
+ "combined_df = combined_df[[col for col in combined_df.columns if \"_\" not in col]]\n",
1103
+ "\n",
1104
+ "\n",
1105
+ "combined_df"
1106
+ ]
1107
+ },
1108
+ {
1109
+ "cell_type": "code",
1110
+ "execution_count": 21,
1111
+ "metadata": {},
1112
+ "outputs": [
1113
+ {
1114
+ "data": {
1115
+ "text/html": [
1116
+ "<div>\n",
1117
+ "<style scoped>\n",
1118
+ " .dataframe tbody tr th:only-of-type {\n",
1119
+ " vertical-align: middle;\n",
1120
+ " }\n",
1121
+ "\n",
1122
+ " .dataframe tbody tr th {\n",
1123
+ " vertical-align: top;\n",
1124
+ " }\n",
1125
+ "\n",
1126
+ " .dataframe thead th {\n",
1127
+ " text-align: right;\n",
1128
+ " }\n",
1129
+ "</style>\n",
1130
+ "<table border=\"1\" class=\"dataframe\">\n",
1131
+ " <thead>\n",
1132
+ " <tr style=\"text-align: right;\">\n",
1133
+ " <th></th>\n",
1134
+ " <th>RegionID</th>\n",
1135
+ " <th>SizeRank</th>\n",
1136
+ " <th>RegionName</th>\n",
1137
+ " <th>RegionType</th>\n",
1138
+ " <th>StateName</th>\n",
1139
+ " <th>Bedroom Count</th>\n",
1140
+ " <th>Home Type</th>\n",
1141
+ " <th>Date</th>\n",
1142
+ " <th>Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)</th>\n",
1143
+ " <th>Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted)</th>\n",
1144
+ " <th>Top Tier ZHVI (Smoothed) (Seasonally Adjusted)</th>\n",
1145
+ " <th>ZHVI</th>\n",
1146
+ " <th>Mid Tier ZHVI</th>\n",
1147
+ " </tr>\n",
1148
+ " </thead>\n",
1149
+ " <tbody>\n",
1150
+ " <tr>\n",
1151
+ " <th>0</th>\n",
1152
+ " <td>3</td>\n",
1153
+ " <td>48</td>\n",
1154
+ " <td>Alaska</td>\n",
1155
+ " <td>state</td>\n",
1156
+ " <td>Alaska</td>\n",
1157
+ " <td>1-Bedrooms</td>\n",
1158
+ " <td>all homes (SFR/condo)</td>\n",
1159
+ " <td>2000-01-31</td>\n",
1160
+ " <td>NaN</td>\n",
1161
+ " <td>NaN</td>\n",
1162
+ " <td>NaN</td>\n",
1163
+ " <td>81310.639504</td>\n",
1164
+ " <td>81310.639504</td>\n",
1165
+ " </tr>\n",
1166
+ " <tr>\n",
1167
+ " <th>1</th>\n",
1168
+ " <td>3</td>\n",
1169
+ " <td>48</td>\n",
1170
+ " <td>Alaska</td>\n",
1171
+ " <td>state</td>\n",
1172
+ " <td>Alaska</td>\n",
1173
+ " <td>1-Bedrooms</td>\n",
1174
+ " <td>all homes (SFR/condo)</td>\n",
1175
+ " <td>2000-02-29</td>\n",
1176
+ " <td>NaN</td>\n",
1177
+ " <td>NaN</td>\n",
1178
+ " <td>NaN</td>\n",
1179
+ " <td>80419.761984</td>\n",
1180
+ " <td>80419.761984</td>\n",
1181
+ " </tr>\n",
1182
+ " <tr>\n",
1183
+ " <th>2</th>\n",
1184
+ " <td>3</td>\n",
1185
+ " <td>48</td>\n",
1186
+ " <td>Alaska</td>\n",
1187
+ " <td>state</td>\n",
1188
+ " <td>Alaska</td>\n",
1189
+ " <td>1-Bedrooms</td>\n",
1190
+ " <td>all homes (SFR/condo)</td>\n",
1191
+ " <td>2000-03-31</td>\n",
1192
+ " <td>NaN</td>\n",
1193
+ " <td>NaN</td>\n",
1194
+ " <td>NaN</td>\n",
1195
+ " <td>80480.449461</td>\n",
1196
+ " <td>80480.449461</td>\n",
1197
+ " </tr>\n",
1198
+ " <tr>\n",
1199
+ " <th>3</th>\n",
1200
+ " <td>3</td>\n",
1201
+ " <td>48</td>\n",
1202
+ " <td>Alaska</td>\n",
1203
+ " <td>state</td>\n",
1204
+ " <td>Alaska</td>\n",
1205
+ " <td>1-Bedrooms</td>\n",
1206
+ " <td>all homes (SFR/condo)</td>\n",
1207
+ " <td>2000-04-30</td>\n",
1208
+ " <td>NaN</td>\n",
1209
+ " <td>NaN</td>\n",
1210
+ " <td>NaN</td>\n",
1211
+ " <td>79799.206525</td>\n",
1212
+ " <td>79799.206525</td>\n",
1213
+ " </tr>\n",
1214
+ " <tr>\n",
1215
+ " <th>4</th>\n",
1216
+ " <td>3</td>\n",
1217
+ " <td>48</td>\n",
1218
+ " <td>Alaska</td>\n",
1219
+ " <td>state</td>\n",
1220
+ " <td>Alaska</td>\n",
1221
+ " <td>1-Bedrooms</td>\n",
1222
+ " <td>all homes (SFR/condo)</td>\n",
1223
+ " <td>2000-05-31</td>\n",
1224
+ " <td>NaN</td>\n",
1225
+ " <td>NaN</td>\n",
1226
+ " <td>NaN</td>\n",
1227
+ " <td>79666.469861</td>\n",
1228
+ " <td>79666.469861</td>\n",
1229
+ " </tr>\n",
1230
+ " <tr>\n",
1231
+ " <th>...</th>\n",
1232
+ " <td>...</td>\n",
1233
+ " <td>...</td>\n",
1234
+ " <td>...</td>\n",
1235
+ " <td>...</td>\n",
1236
+ " <td>...</td>\n",
1237
+ " <td>...</td>\n",
1238
+ " <td>...</td>\n",
1239
+ " <td>...</td>\n",
1240
+ " <td>...</td>\n",
1241
+ " <td>...</td>\n",
1242
+ " <td>...</td>\n",
1243
+ " <td>...</td>\n",
1244
+ " <td>...</td>\n",
1245
+ " </tr>\n",
1246
+ " <tr>\n",
1247
+ " <th>117907</th>\n",
1248
+ " <td>62</td>\n",
1249
+ " <td>51</td>\n",
1250
+ " <td>Wyoming</td>\n",
1251
+ " <td>state</td>\n",
1252
+ " <td>Wyoming</td>\n",
1253
+ " <td>All Bedrooms</td>\n",
1254
+ " <td>condo</td>\n",
1255
+ " <td>2023-09-30</td>\n",
1256
+ " <td>NaN</td>\n",
1257
+ " <td>NaN</td>\n",
1258
+ " <td>NaN</td>\n",
1259
+ " <td>486974.735908</td>\n",
1260
+ " <td>486974.735908</td>\n",
1261
+ " </tr>\n",
1262
+ " <tr>\n",
1263
+ " <th>117908</th>\n",
1264
+ " <td>62</td>\n",
1265
+ " <td>51</td>\n",
1266
+ " <td>Wyoming</td>\n",
1267
+ " <td>state</td>\n",
1268
+ " <td>Wyoming</td>\n",
1269
+ " <td>All Bedrooms</td>\n",
1270
+ " <td>condo</td>\n",
1271
+ " <td>2023-10-31</td>\n",
1272
+ " <td>NaN</td>\n",
1273
+ " <td>NaN</td>\n",
1274
+ " <td>NaN</td>\n",
1275
+ " <td>485847.539614</td>\n",
1276
+ " <td>485847.539614</td>\n",
1277
+ " </tr>\n",
1278
+ " <tr>\n",
1279
+ " <th>117909</th>\n",
1280
+ " <td>62</td>\n",
1281
+ " <td>51</td>\n",
1282
+ " <td>Wyoming</td>\n",
1283
+ " <td>state</td>\n",
1284
+ " <td>Wyoming</td>\n",
1285
+ " <td>All Bedrooms</td>\n",
1286
+ " <td>condo</td>\n",
1287
+ " <td>2023-11-30</td>\n",
1288
+ " <td>NaN</td>\n",
1289
+ " <td>NaN</td>\n",
1290
+ " <td>NaN</td>\n",
1291
+ " <td>484223.885775</td>\n",
1292
+ " <td>484223.885775</td>\n",
1293
+ " </tr>\n",
1294
+ " <tr>\n",
1295
+ " <th>117910</th>\n",
1296
+ " <td>62</td>\n",
1297
+ " <td>51</td>\n",
1298
+ " <td>Wyoming</td>\n",
1299
+ " <td>state</td>\n",
1300
+ " <td>Wyoming</td>\n",
1301
+ " <td>All Bedrooms</td>\n",
1302
+ " <td>condo</td>\n",
1303
+ " <td>2023-12-31</td>\n",
1304
+ " <td>NaN</td>\n",
1305
+ " <td>NaN</td>\n",
1306
+ " <td>NaN</td>\n",
1307
+ " <td>481522.403338</td>\n",
1308
+ " <td>481522.403338</td>\n",
1309
+ " </tr>\n",
1310
+ " <tr>\n",
1311
+ " <th>117911</th>\n",
1312
+ " <td>62</td>\n",
1313
+ " <td>51</td>\n",
1314
+ " <td>Wyoming</td>\n",
1315
+ " <td>state</td>\n",
1316
+ " <td>Wyoming</td>\n",
1317
+ " <td>All Bedrooms</td>\n",
1318
+ " <td>condo</td>\n",
1319
+ " <td>2024-01-31</td>\n",
1320
+ " <td>NaN</td>\n",
1321
+ " <td>NaN</td>\n",
1322
+ " <td>NaN</td>\n",
1323
+ " <td>481181.718200</td>\n",
1324
+ " <td>481181.718200</td>\n",
1325
+ " </tr>\n",
1326
+ " </tbody>\n",
1327
+ "</table>\n",
1328
+ "<p>117912 rows × 13 columns</p>\n",
1329
+ "</div>"
1330
+ ],
1331
+ "text/plain": [
1332
+ " RegionID SizeRank RegionName RegionType StateName Bedroom Count \\\n",
1333
+ "0 3 48 Alaska state Alaska 1-Bedrooms \n",
1334
+ "1 3 48 Alaska state Alaska 1-Bedrooms \n",
1335
+ "2 3 48 Alaska state Alaska 1-Bedrooms \n",
1336
+ "3 3 48 Alaska state Alaska 1-Bedrooms \n",
1337
+ "4 3 48 Alaska state Alaska 1-Bedrooms \n",
1338
+ "... ... ... ... ... ... ... \n",
1339
+ "117907 62 51 Wyoming state Wyoming All Bedrooms \n",
1340
+ "117908 62 51 Wyoming state Wyoming All Bedrooms \n",
1341
+ "117909 62 51 Wyoming state Wyoming All Bedrooms \n",
1342
+ "117910 62 51 Wyoming state Wyoming All Bedrooms \n",
1343
+ "117911 62 51 Wyoming state Wyoming All Bedrooms \n",
1344
+ "\n",
1345
+ " Home Type Date \\\n",
1346
+ "0 all homes (SFR/condo) 2000-01-31 \n",
1347
+ "1 all homes (SFR/condo) 2000-02-29 \n",
1348
+ "2 all homes (SFR/condo) 2000-03-31 \n",
1349
+ "3 all homes (SFR/condo) 2000-04-30 \n",
1350
+ "4 all homes (SFR/condo) 2000-05-31 \n",
1351
+ "... ... ... \n",
1352
+ "117907 condo 2023-09-30 \n",
1353
+ "117908 condo 2023-10-31 \n",
1354
+ "117909 condo 2023-11-30 \n",
1355
+ "117910 condo 2023-12-31 \n",
1356
+ "117911 condo 2024-01-31 \n",
1357
+ "\n",
1358
+ " Mid Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n",
1359
+ "0 NaN \n",
1360
+ "1 NaN \n",
1361
+ "2 NaN \n",
1362
+ "3 NaN \n",
1363
+ "4 NaN \n",
1364
+ "... ... \n",
1365
+ "117907 NaN \n",
1366
+ "117908 NaN \n",
1367
+ "117909 NaN \n",
1368
+ "117910 NaN \n",
1369
+ "117911 NaN \n",
1370
+ "\n",
1371
+ " Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n",
1372
+ "0 NaN \n",
1373
+ "1 NaN \n",
1374
+ "2 NaN \n",
1375
+ "3 NaN \n",
1376
+ "4 NaN \n",
1377
+ "... ... \n",
1378
+ "117907 NaN \n",
1379
+ "117908 NaN \n",
1380
+ "117909 NaN \n",
1381
+ "117910 NaN \n",
1382
+ "117911 NaN \n",
1383
+ "\n",
1384
+ " Top Tier ZHVI (Smoothed) (Seasonally Adjusted) ZHVI \\\n",
1385
+ "0 NaN 81310.639504 \n",
1386
+ "1 NaN 80419.761984 \n",
1387
+ "2 NaN 80480.449461 \n",
1388
+ "3 NaN 79799.206525 \n",
1389
+ "4 NaN 79666.469861 \n",
1390
+ "... ... ... \n",
1391
+ "117907 NaN 486974.735908 \n",
1392
+ "117908 NaN 485847.539614 \n",
1393
+ "117909 NaN 484223.885775 \n",
1394
+ "117910 NaN 481522.403338 \n",
1395
+ "117911 NaN 481181.718200 \n",
1396
+ "\n",
1397
+ " Mid Tier ZHVI \n",
1398
+ "0 81310.639504 \n",
1399
+ "1 80419.761984 \n",
1400
+ "2 80480.449461 \n",
1401
+ "3 79799.206525 \n",
1402
+ "4 79666.469861 \n",
1403
+ "... ... \n",
1404
+ "117907 486974.735908 \n",
1405
+ "117908 485847.539614 \n",
1406
+ "117909 484223.885775 \n",
1407
+ "117910 481522.403338 \n",
1408
+ "117911 481181.718200 \n",
1409
+ "\n",
1410
+ "[117912 rows x 13 columns]"
1411
+ ]
1412
+ },
1413
+ "execution_count": 21,
1414
+ "metadata": {},
1415
+ "output_type": "execute_result"
1416
+ }
1417
+ ],
1418
+ "source": [
1419
+ "final_df = combined_df\n",
1420
+ "\n",
1421
+ "for index, row in final_df.iterrows():\n",
1422
+ " if row[\"RegionType\"] == \"city\":\n",
1423
+ " final_df.at[index, \"City\"] = row[\"RegionName\"]\n",
1424
+ " elif row[\"RegionType\"] == \"county\":\n",
1425
+ " final_df.at[index, \"County\"] = row[\"RegionName\"]\n",
1426
+ " if row[\"RegionType\"] == \"state\":\n",
1427
+ " final_df.at[index, \"StateName\"] = row[\"RegionName\"]\n",
1428
+ "\n",
1429
+ "# coalesce State and StateName columns\n",
1430
+ "# final_df[\"State\"] = final_df[\"State\"].combine_first(final_df[\"StateName\"])\n",
1431
+ "# final_df[\"County\"] = final_df[\"County\"].combine_first(final_df[\"CountyName\"])\n",
1432
+ "\n",
1433
+ "# final_df = final_df.drop(\n",
1434
+ "# columns=[\n",
1435
+ "# \"StateName\",\n",
1436
+ "# # \"CountyName\"\n",
1437
+ "# ]\n",
1438
+ "# )\n",
1439
+ "final_df"
1440
+ ]
1441
+ },
1442
+ {
1443
+ "cell_type": "code",
1444
+ "execution_count": 22,
1445
+ "metadata": {},
1446
+ "outputs": [
1447
+ {
1448
+ "data": {
1449
+ "text/html": [
1450
+ "<div>\n",
1451
+ "<style scoped>\n",
1452
+ " .dataframe tbody tr th:only-of-type {\n",
1453
+ " vertical-align: middle;\n",
1454
+ " }\n",
1455
+ "\n",
1456
+ " .dataframe tbody tr th {\n",
1457
+ " vertical-align: top;\n",
1458
+ " }\n",
1459
+ "\n",
1460
+ " .dataframe thead th {\n",
1461
+ " text-align: right;\n",
1462
+ " }\n",
1463
+ "</style>\n",
1464
+ "<table border=\"1\" class=\"dataframe\">\n",
1465
+ " <thead>\n",
1466
+ " <tr style=\"text-align: right;\">\n",
1467
+ " <th></th>\n",
1468
+ " <th>Region ID</th>\n",
1469
+ " <th>Size Rank</th>\n",
1470
+ " <th>Region</th>\n",
1471
+ " <th>Region Type</th>\n",
1472
+ " <th>State</th>\n",
1473
+ " <th>Bedroom Count</th>\n",
1474
+ " <th>Home Type</th>\n",
1475
+ " <th>Date</th>\n",
1476
+ " <th>Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)</th>\n",
1477
+ " <th>Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted)</th>\n",
1478
+ " <th>Top Tier ZHVI (Smoothed) (Seasonally Adjusted)</th>\n",
1479
+ " <th>ZHVI</th>\n",
1480
+ " <th>Mid Tier ZHVI</th>\n",
1481
+ " </tr>\n",
1482
+ " </thead>\n",
1483
+ " <tbody>\n",
1484
+ " <tr>\n",
1485
+ " <th>0</th>\n",
1486
+ " <td>3</td>\n",
1487
+ " <td>48</td>\n",
1488
+ " <td>Alaska</td>\n",
1489
+ " <td>state</td>\n",
1490
+ " <td>Alaska</td>\n",
1491
+ " <td>1-Bedrooms</td>\n",
1492
+ " <td>all homes (SFR/condo)</td>\n",
1493
+ " <td>2000-01-31</td>\n",
1494
+ " <td>NaN</td>\n",
1495
+ " <td>NaN</td>\n",
1496
+ " <td>NaN</td>\n",
1497
+ " <td>81310.639504</td>\n",
1498
+ " <td>81310.639504</td>\n",
1499
+ " </tr>\n",
1500
+ " <tr>\n",
1501
+ " <th>1</th>\n",
1502
+ " <td>3</td>\n",
1503
+ " <td>48</td>\n",
1504
+ " <td>Alaska</td>\n",
1505
+ " <td>state</td>\n",
1506
+ " <td>Alaska</td>\n",
1507
+ " <td>1-Bedrooms</td>\n",
1508
+ " <td>all homes (SFR/condo)</td>\n",
1509
+ " <td>2000-02-29</td>\n",
1510
+ " <td>NaN</td>\n",
1511
+ " <td>NaN</td>\n",
1512
+ " <td>NaN</td>\n",
1513
+ " <td>80419.761984</td>\n",
1514
+ " <td>80419.761984</td>\n",
1515
+ " </tr>\n",
1516
+ " <tr>\n",
1517
+ " <th>2</th>\n",
1518
+ " <td>3</td>\n",
1519
+ " <td>48</td>\n",
1520
+ " <td>Alaska</td>\n",
1521
+ " <td>state</td>\n",
1522
+ " <td>Alaska</td>\n",
1523
+ " <td>1-Bedrooms</td>\n",
1524
+ " <td>all homes (SFR/condo)</td>\n",
1525
+ " <td>2000-03-31</td>\n",
1526
+ " <td>NaN</td>\n",
1527
+ " <td>NaN</td>\n",
1528
+ " <td>NaN</td>\n",
1529
+ " <td>80480.449461</td>\n",
1530
+ " <td>80480.449461</td>\n",
1531
+ " </tr>\n",
1532
+ " <tr>\n",
1533
+ " <th>3</th>\n",
1534
+ " <td>3</td>\n",
1535
+ " <td>48</td>\n",
1536
+ " <td>Alaska</td>\n",
1537
+ " <td>state</td>\n",
1538
+ " <td>Alaska</td>\n",
1539
+ " <td>1-Bedrooms</td>\n",
1540
+ " <td>all homes (SFR/condo)</td>\n",
1541
+ " <td>2000-04-30</td>\n",
1542
+ " <td>NaN</td>\n",
1543
+ " <td>NaN</td>\n",
1544
+ " <td>NaN</td>\n",
1545
+ " <td>79799.206525</td>\n",
1546
+ " <td>79799.206525</td>\n",
1547
+ " </tr>\n",
1548
+ " <tr>\n",
1549
+ " <th>4</th>\n",
1550
+ " <td>3</td>\n",
1551
+ " <td>48</td>\n",
1552
+ " <td>Alaska</td>\n",
1553
+ " <td>state</td>\n",
1554
+ " <td>Alaska</td>\n",
1555
+ " <td>1-Bedrooms</td>\n",
1556
+ " <td>all homes (SFR/condo)</td>\n",
1557
+ " <td>2000-05-31</td>\n",
1558
+ " <td>NaN</td>\n",
1559
+ " <td>NaN</td>\n",
1560
+ " <td>NaN</td>\n",
1561
+ " <td>79666.469861</td>\n",
1562
+ " <td>79666.469861</td>\n",
1563
+ " </tr>\n",
1564
+ " <tr>\n",
1565
+ " <th>...</th>\n",
1566
+ " <td>...</td>\n",
1567
+ " <td>...</td>\n",
1568
+ " <td>...</td>\n",
1569
+ " <td>...</td>\n",
1570
+ " <td>...</td>\n",
1571
+ " <td>...</td>\n",
1572
+ " <td>...</td>\n",
1573
+ " <td>...</td>\n",
1574
+ " <td>...</td>\n",
1575
+ " <td>...</td>\n",
1576
+ " <td>...</td>\n",
1577
+ " <td>...</td>\n",
1578
+ " <td>...</td>\n",
1579
+ " </tr>\n",
1580
+ " <tr>\n",
1581
+ " <th>117907</th>\n",
1582
+ " <td>62</td>\n",
1583
+ " <td>51</td>\n",
1584
+ " <td>Wyoming</td>\n",
1585
+ " <td>state</td>\n",
1586
+ " <td>Wyoming</td>\n",
1587
+ " <td>All Bedrooms</td>\n",
1588
+ " <td>condo</td>\n",
1589
+ " <td>2023-09-30</td>\n",
1590
+ " <td>NaN</td>\n",
1591
+ " <td>NaN</td>\n",
1592
+ " <td>NaN</td>\n",
1593
+ " <td>486974.735908</td>\n",
1594
+ " <td>486974.735908</td>\n",
1595
+ " </tr>\n",
1596
+ " <tr>\n",
1597
+ " <th>117908</th>\n",
1598
+ " <td>62</td>\n",
1599
+ " <td>51</td>\n",
1600
+ " <td>Wyoming</td>\n",
1601
+ " <td>state</td>\n",
1602
+ " <td>Wyoming</td>\n",
1603
+ " <td>All Bedrooms</td>\n",
1604
+ " <td>condo</td>\n",
1605
+ " <td>2023-10-31</td>\n",
1606
+ " <td>NaN</td>\n",
1607
+ " <td>NaN</td>\n",
1608
+ " <td>NaN</td>\n",
1609
+ " <td>485847.539614</td>\n",
1610
+ " <td>485847.539614</td>\n",
1611
+ " </tr>\n",
1612
+ " <tr>\n",
1613
+ " <th>117909</th>\n",
1614
+ " <td>62</td>\n",
1615
+ " <td>51</td>\n",
1616
+ " <td>Wyoming</td>\n",
1617
+ " <td>state</td>\n",
1618
+ " <td>Wyoming</td>\n",
1619
+ " <td>All Bedrooms</td>\n",
1620
+ " <td>condo</td>\n",
1621
+ " <td>2023-11-30</td>\n",
1622
+ " <td>NaN</td>\n",
1623
+ " <td>NaN</td>\n",
1624
+ " <td>NaN</td>\n",
1625
+ " <td>484223.885775</td>\n",
1626
+ " <td>484223.885775</td>\n",
1627
+ " </tr>\n",
1628
+ " <tr>\n",
1629
+ " <th>117910</th>\n",
1630
+ " <td>62</td>\n",
1631
+ " <td>51</td>\n",
1632
+ " <td>Wyoming</td>\n",
1633
+ " <td>state</td>\n",
1634
+ " <td>Wyoming</td>\n",
1635
+ " <td>All Bedrooms</td>\n",
1636
+ " <td>condo</td>\n",
1637
+ " <td>2023-12-31</td>\n",
1638
+ " <td>NaN</td>\n",
1639
+ " <td>NaN</td>\n",
1640
+ " <td>NaN</td>\n",
1641
+ " <td>481522.403338</td>\n",
1642
+ " <td>481522.403338</td>\n",
1643
+ " </tr>\n",
1644
+ " <tr>\n",
1645
+ " <th>117911</th>\n",
1646
+ " <td>62</td>\n",
1647
+ " <td>51</td>\n",
1648
+ " <td>Wyoming</td>\n",
1649
+ " <td>state</td>\n",
1650
+ " <td>Wyoming</td>\n",
1651
+ " <td>All Bedrooms</td>\n",
1652
+ " <td>condo</td>\n",
1653
+ " <td>2024-01-31</td>\n",
1654
+ " <td>NaN</td>\n",
1655
+ " <td>NaN</td>\n",
1656
+ " <td>NaN</td>\n",
1657
+ " <td>481181.718200</td>\n",
1658
+ " <td>481181.718200</td>\n",
1659
+ " </tr>\n",
1660
+ " </tbody>\n",
1661
+ "</table>\n",
1662
+ "<p>117912 rows × 13 columns</p>\n",
1663
+ "</div>"
1664
+ ],
1665
+ "text/plain": [
1666
+ " Region ID Size Rank Region Region Type State Bedroom Count \\\n",
1667
+ "0 3 48 Alaska state Alaska 1-Bedrooms \n",
1668
+ "1 3 48 Alaska state Alaska 1-Bedrooms \n",
1669
+ "2 3 48 Alaska state Alaska 1-Bedrooms \n",
1670
+ "3 3 48 Alaska state Alaska 1-Bedrooms \n",
1671
+ "4 3 48 Alaska state Alaska 1-Bedrooms \n",
1672
+ "... ... ... ... ... ... ... \n",
1673
+ "117907 62 51 Wyoming state Wyoming All Bedrooms \n",
1674
+ "117908 62 51 Wyoming state Wyoming All Bedrooms \n",
1675
+ "117909 62 51 Wyoming state Wyoming All Bedrooms \n",
1676
+ "117910 62 51 Wyoming state Wyoming All Bedrooms \n",
1677
+ "117911 62 51 Wyoming state Wyoming All Bedrooms \n",
1678
+ "\n",
1679
+ " Home Type Date \\\n",
1680
+ "0 all homes (SFR/condo) 2000-01-31 \n",
1681
+ "1 all homes (SFR/condo) 2000-02-29 \n",
1682
+ "2 all homes (SFR/condo) 2000-03-31 \n",
1683
+ "3 all homes (SFR/condo) 2000-04-30 \n",
1684
+ "4 all homes (SFR/condo) 2000-05-31 \n",
1685
+ "... ... ... \n",
1686
+ "117907 condo 2023-09-30 \n",
1687
+ "117908 condo 2023-10-31 \n",
1688
+ "117909 condo 2023-11-30 \n",
1689
+ "117910 condo 2023-12-31 \n",
1690
+ "117911 condo 2024-01-31 \n",
1691
+ "\n",
1692
+ " Mid Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n",
1693
+ "0 NaN \n",
1694
+ "1 NaN \n",
1695
+ "2 NaN \n",
1696
+ "3 NaN \n",
1697
+ "4 NaN \n",
1698
+ "... ... \n",
1699
+ "117907 NaN \n",
1700
+ "117908 NaN \n",
1701
+ "117909 NaN \n",
1702
+ "117910 NaN \n",
1703
+ "117911 NaN \n",
1704
+ "\n",
1705
+ " Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n",
1706
+ "0 NaN \n",
1707
+ "1 NaN \n",
1708
+ "2 NaN \n",
1709
+ "3 NaN \n",
1710
+ "4 NaN \n",
1711
+ "... ... \n",
1712
+ "117907 NaN \n",
1713
+ "117908 NaN \n",
1714
+ "117909 NaN \n",
1715
+ "117910 NaN \n",
1716
+ "117911 NaN \n",
1717
+ "\n",
1718
+ " Top Tier ZHVI (Smoothed) (Seasonally Adjusted) ZHVI \\\n",
1719
+ "0 NaN 81310.639504 \n",
1720
+ "1 NaN 80419.761984 \n",
1721
+ "2 NaN 80480.449461 \n",
1722
+ "3 NaN 79799.206525 \n",
1723
+ "4 NaN 79666.469861 \n",
1724
+ "... ... ... \n",
1725
+ "117907 NaN 486974.735908 \n",
1726
+ "117908 NaN 485847.539614 \n",
1727
+ "117909 NaN 484223.885775 \n",
1728
+ "117910 NaN 481522.403338 \n",
1729
+ "117911 NaN 481181.718200 \n",
1730
+ "\n",
1731
+ " Mid Tier ZHVI \n",
1732
+ "0 81310.639504 \n",
1733
+ "1 80419.761984 \n",
1734
+ "2 80480.449461 \n",
1735
+ "3 79799.206525 \n",
1736
+ "4 79666.469861 \n",
1737
+ "... ... \n",
1738
+ "117907 486974.735908 \n",
1739
+ "117908 485847.539614 \n",
1740
+ "117909 484223.885775 \n",
1741
+ "117910 481522.403338 \n",
1742
+ "117911 481181.718200 \n",
1743
+ "\n",
1744
+ "[117912 rows x 13 columns]"
1745
+ ]
1746
+ },
1747
+ "execution_count": 22,
1748
+ "metadata": {},
1749
+ "output_type": "execute_result"
1750
+ }
1751
+ ],
1752
+ "source": [
1753
+ "final_df = final_df.rename(\n",
1754
+ " columns={\n",
1755
+ " \"RegionID\": \"Region ID\",\n",
1756
+ " \"SizeRank\": \"Size Rank\",\n",
1757
+ " \"RegionName\": \"Region\",\n",
1758
+ " \"RegionType\": \"Region Type\",\n",
1759
+ " \"StateCodeFIPS\": \"State Code FIPS\",\n",
1760
+ " \"StateName\": \"State\",\n",
1761
+ " \"MunicipalCodeFIPS\": \"Municipal Code FIPS\",\n",
1762
+ " }\n",
1763
+ ")\n",
1764
+ "\n",
1765
+ "final_df"
1766
+ ]
1767
+ },
1768
+ {
1769
+ "cell_type": "code",
1770
+ "execution_count": 23,
1771
+ "metadata": {},
1772
+ "outputs": [],
1773
+ "source": [
1774
+ "if not os.path.exists(FULL_PROCESSED_DIR_PATH):\n",
1775
+ " os.makedirs(FULL_PROCESSED_DIR_PATH)\n",
1776
+ "\n",
1777
+ "final_df.to_json(FULL_PROCESSED_DIR_PATH + \"final.jsonl\", orient=\"records\", lines=True)"
1778
+ ]
1779
+ }
1780
+ ],
1781
+ "metadata": {
1782
+ "kernelspec": {
1783
+ "display_name": "Python 3",
1784
+ "language": "python",
1785
+ "name": "python3"
1786
+ },
1787
+ "language_info": {
1788
+ "codemirror_mode": {
1789
+ "name": "ipython",
1790
+ "version": 3
1791
+ },
1792
+ "file_extension": ".py",
1793
+ "mimetype": "text/x-python",
1794
+ "name": "python",
1795
+ "nbconvert_exporter": "python",
1796
+ "pygments_lexer": "ipython3",
1797
+ "version": "3.12.2"
1798
+ }
1799
+ },
1800
+ "nbformat": 4,
1801
+ "nbformat_minor": 2
1802
+ }
processors/rentals.ipynb CHANGED
@@ -352,8 +352,6 @@
352
  "\n",
353
  " if \"_sfrcondomfr_\" in filename:\n",
354
  " cur_df[\"Home Type\"] = \"all homes plus multifamily\"\n",
355
- " # skip for now\n",
356
- " # continue\n",
357
  " # change column type to string\n",
358
  " cur_df[\"RegionName\"] = cur_df[\"RegionName\"].astype(str)\n",
359
  " if \"City\" in filename:\n",
 
352
  "\n",
353
  " if \"_sfrcondomfr_\" in filename:\n",
354
  " cur_df[\"Home Type\"] = \"all homes plus multifamily\"\n",
 
 
355
  " # change column type to string\n",
356
  " cur_df[\"RegionName\"] = cur_df[\"RegionName\"].astype(str)\n",
357
  " if \"City\" in filename:\n",
processors/sales.ipynb ADDED
@@ -0,0 +1,1110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 2,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import pandas as pd\n",
10
+ "import os"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 3,
16
+ "metadata": {},
17
+ "outputs": [],
18
+ "source": [
19
+ "DATA_DIR = \"../data\"\n",
20
+ "PROCESSED_DIR = \"../processed/\"\n",
21
+ "FACET_DIR = \"sales/\"\n",
22
+ "FULL_DATA_DIR_PATH = os.path.join(DATA_DIR, FACET_DIR)\n",
23
+ "FULL_PROCESSED_DIR_PATH = os.path.join(PROCESSED_DIR, FACET_DIR)"
24
+ ]
25
+ },
26
+ {
27
+ "cell_type": "code",
28
+ "execution_count": 5,
29
+ "metadata": {},
30
+ "outputs": [
31
+ {
32
+ "name": "stdout",
33
+ "output_type": "stream",
34
+ "text": [
35
+ "processing Metro_mean_sale_to_list_uc_sfrcondo_sm_month.csv\n",
36
+ "processing Metro_median_sale_to_list_uc_sfrcondo_week.csv\n",
37
+ "processing Metro_median_sale_price_uc_sfr_week.csv\n",
38
+ "processing Metro_pct_sold_below_list_uc_sfrcondo_sm_month.csv\n",
39
+ "processing Metro_median_sale_price_uc_sfr_sm_sa_week.csv\n",
40
+ "processing Metro_pct_sold_below_list_uc_sfrcondo_month.csv\n",
41
+ "processing Metro_median_sale_price_uc_sfrcondo_sm_week.csv\n",
42
+ "processing Metro_pct_sold_below_list_uc_sfrcondo_sm_week.csv\n",
43
+ "processing Metro_median_sale_price_uc_sfr_month.csv\n",
44
+ "processing Metro_median_sale_to_list_uc_sfrcondo_sm_month.csv\n",
45
+ "processing Metro_pct_sold_above_list_uc_sfrcondo_month.csv\n",
46
+ "processing Metro_median_sale_to_list_uc_sfrcondo_sm_week.csv\n",
47
+ "processing Metro_median_sale_price_uc_sfrcondo_sm_sa_month.csv\n",
48
+ "processing Metro_sales_count_now_uc_sfrcondo_month.csv\n",
49
+ "processing Metro_pct_sold_above_list_uc_sfrcondo_week.csv\n",
50
+ "processing Metro_mean_sale_to_list_uc_sfrcondo_sm_week.csv\n",
51
+ "processing Metro_median_sale_price_uc_sfrcondo_sm_month.csv\n",
52
+ "processing Metro_mean_sale_to_list_uc_sfrcondo_week.csv\n",
53
+ "processing Metro_median_sale_price_uc_sfr_sm_month.csv\n",
54
+ "processing Metro_median_sale_to_list_uc_sfrcondo_month.csv\n",
55
+ "processing Metro_median_sale_price_uc_sfrcondo_sm_sa_week.csv\n",
56
+ "processing Metro_pct_sold_below_list_uc_sfrcondo_week.csv\n",
57
+ "processing Metro_median_sale_price_uc_sfrcondo_week.csv\n",
58
+ "processing Metro_mean_sale_to_list_uc_sfrcondo_month.csv\n",
59
+ "processing Metro_pct_sold_above_list_uc_sfrcondo_sm_week.csv\n",
60
+ "processing Metro_median_sale_price_uc_sfr_sm_week.csv\n",
61
+ "processing Metro_median_sale_price_uc_sfrcondo_month.csv\n",
62
+ "processing Metro_pct_sold_above_list_uc_sfrcondo_sm_month.csv\n"
63
+ ]
64
+ },
65
+ {
66
+ "data": {
67
+ "text/html": [
68
+ "<div>\n",
69
+ "<style scoped>\n",
70
+ " .dataframe tbody tr th:only-of-type {\n",
71
+ " vertical-align: middle;\n",
72
+ " }\n",
73
+ "\n",
74
+ " .dataframe tbody tr th {\n",
75
+ " vertical-align: top;\n",
76
+ " }\n",
77
+ "\n",
78
+ " .dataframe thead th {\n",
79
+ " text-align: right;\n",
80
+ " }\n",
81
+ "</style>\n",
82
+ "<table border=\"1\" class=\"dataframe\">\n",
83
+ " <thead>\n",
84
+ " <tr style=\"text-align: right;\">\n",
85
+ " <th></th>\n",
86
+ " <th>RegionID</th>\n",
87
+ " <th>SizeRank</th>\n",
88
+ " <th>RegionName</th>\n",
89
+ " <th>RegionType</th>\n",
90
+ " <th>StateName</th>\n",
91
+ " <th>Home Type</th>\n",
92
+ " <th>Date</th>\n",
93
+ " <th>Mean Sale to List Ratio (Smoothed)</th>\n",
94
+ " <th>Median Sale to List Ratio</th>\n",
95
+ " <th>Median Sale Price</th>\n",
96
+ " <th>% Sold Below List (Smoothed)</th>\n",
97
+ " <th>Median Sale Price (Smoothed) (Seasonally Adjusted)</th>\n",
98
+ " <th>% Sold Below List</th>\n",
99
+ " <th>Median Sale Price (Smoothed)</th>\n",
100
+ " <th>Median Sale to List Ratio (Smoothed)</th>\n",
101
+ " <th>% Sold Above List</th>\n",
102
+ " <th>Nowcast</th>\n",
103
+ " <th>Mean Sale to List Ratio</th>\n",
104
+ " <th>% Sold Above List (Smoothed)</th>\n",
105
+ " </tr>\n",
106
+ " </thead>\n",
107
+ " <tbody>\n",
108
+ " <tr>\n",
109
+ " <th>0</th>\n",
110
+ " <td>102001</td>\n",
111
+ " <td>0</td>\n",
112
+ " <td>United States</td>\n",
113
+ " <td>country</td>\n",
114
+ " <td>NaN</td>\n",
115
+ " <td>SFR</td>\n",
116
+ " <td>2008-02-02</td>\n",
117
+ " <td>NaN</td>\n",
118
+ " <td>NaN</td>\n",
119
+ " <td>172000.0</td>\n",
120
+ " <td>NaN</td>\n",
121
+ " <td>NaN</td>\n",
122
+ " <td>NaN</td>\n",
123
+ " <td>NaN</td>\n",
124
+ " <td>NaN</td>\n",
125
+ " <td>NaN</td>\n",
126
+ " <td>NaN</td>\n",
127
+ " <td>NaN</td>\n",
128
+ " <td>NaN</td>\n",
129
+ " </tr>\n",
130
+ " <tr>\n",
131
+ " <th>1</th>\n",
132
+ " <td>102001</td>\n",
133
+ " <td>0</td>\n",
134
+ " <td>United States</td>\n",
135
+ " <td>country</td>\n",
136
+ " <td>NaN</td>\n",
137
+ " <td>SFR</td>\n",
138
+ " <td>2008-02-09</td>\n",
139
+ " <td>NaN</td>\n",
140
+ " <td>NaN</td>\n",
141
+ " <td>165400.0</td>\n",
142
+ " <td>NaN</td>\n",
143
+ " <td>NaN</td>\n",
144
+ " <td>NaN</td>\n",
145
+ " <td>NaN</td>\n",
146
+ " <td>NaN</td>\n",
147
+ " <td>NaN</td>\n",
148
+ " <td>NaN</td>\n",
149
+ " <td>NaN</td>\n",
150
+ " <td>NaN</td>\n",
151
+ " </tr>\n",
152
+ " <tr>\n",
153
+ " <th>2</th>\n",
154
+ " <td>102001</td>\n",
155
+ " <td>0</td>\n",
156
+ " <td>United States</td>\n",
157
+ " <td>country</td>\n",
158
+ " <td>NaN</td>\n",
159
+ " <td>SFR</td>\n",
160
+ " <td>2008-02-16</td>\n",
161
+ " <td>NaN</td>\n",
162
+ " <td>NaN</td>\n",
163
+ " <td>168000.0</td>\n",
164
+ " <td>NaN</td>\n",
165
+ " <td>NaN</td>\n",
166
+ " <td>NaN</td>\n",
167
+ " <td>NaN</td>\n",
168
+ " <td>NaN</td>\n",
169
+ " <td>NaN</td>\n",
170
+ " <td>NaN</td>\n",
171
+ " <td>NaN</td>\n",
172
+ " <td>NaN</td>\n",
173
+ " </tr>\n",
174
+ " <tr>\n",
175
+ " <th>3</th>\n",
176
+ " <td>102001</td>\n",
177
+ " <td>0</td>\n",
178
+ " <td>United States</td>\n",
179
+ " <td>country</td>\n",
180
+ " <td>NaN</td>\n",
181
+ " <td>SFR</td>\n",
182
+ " <td>2008-02-23</td>\n",
183
+ " <td>NaN</td>\n",
184
+ " <td>NaN</td>\n",
185
+ " <td>165000.0</td>\n",
186
+ " <td>NaN</td>\n",
187
+ " <td>NaN</td>\n",
188
+ " <td>NaN</td>\n",
189
+ " <td>167600.0</td>\n",
190
+ " <td>NaN</td>\n",
191
+ " <td>NaN</td>\n",
192
+ " <td>NaN</td>\n",
193
+ " <td>NaN</td>\n",
194
+ " <td>NaN</td>\n",
195
+ " </tr>\n",
196
+ " <tr>\n",
197
+ " <th>4</th>\n",
198
+ " <td>102001</td>\n",
199
+ " <td>0</td>\n",
200
+ " <td>United States</td>\n",
201
+ " <td>country</td>\n",
202
+ " <td>NaN</td>\n",
203
+ " <td>SFR</td>\n",
204
+ " <td>2008-02-29</td>\n",
205
+ " <td>NaN</td>\n",
206
+ " <td>NaN</td>\n",
207
+ " <td>NaN</td>\n",
208
+ " <td>NaN</td>\n",
209
+ " <td>NaN</td>\n",
210
+ " <td>NaN</td>\n",
211
+ " <td>NaN</td>\n",
212
+ " <td>NaN</td>\n",
213
+ " <td>NaN</td>\n",
214
+ " <td>NaN</td>\n",
215
+ " <td>NaN</td>\n",
216
+ " <td>NaN</td>\n",
217
+ " </tr>\n",
218
+ " <tr>\n",
219
+ " <th>...</th>\n",
220
+ " <td>...</td>\n",
221
+ " <td>...</td>\n",
222
+ " <td>...</td>\n",
223
+ " <td>...</td>\n",
224
+ " <td>...</td>\n",
225
+ " <td>...</td>\n",
226
+ " <td>...</td>\n",
227
+ " <td>...</td>\n",
228
+ " <td>...</td>\n",
229
+ " <td>...</td>\n",
230
+ " <td>...</td>\n",
231
+ " <td>...</td>\n",
232
+ " <td>...</td>\n",
233
+ " <td>...</td>\n",
234
+ " <td>...</td>\n",
235
+ " <td>...</td>\n",
236
+ " <td>...</td>\n",
237
+ " <td>...</td>\n",
238
+ " <td>...</td>\n",
239
+ " </tr>\n",
240
+ " <tr>\n",
241
+ " <th>504603</th>\n",
242
+ " <td>845167</td>\n",
243
+ " <td>296</td>\n",
244
+ " <td>Ottawa, IL</td>\n",
245
+ " <td>msa</td>\n",
246
+ " <td>IL</td>\n",
247
+ " <td>all homes</td>\n",
248
+ " <td>2023-07-31</td>\n",
249
+ " <td>0.976219</td>\n",
250
+ " <td>NaN</td>\n",
251
+ " <td>NaN</td>\n",
252
+ " <td>0.554969</td>\n",
253
+ " <td>127574.0</td>\n",
254
+ " <td>0.491379</td>\n",
255
+ " <td>133500.0</td>\n",
256
+ " <td>0.985172</td>\n",
257
+ " <td>0.312332</td>\n",
258
+ " <td>NaN</td>\n",
259
+ " <td>0.979227</td>\n",
260
+ " <td>0.312332</td>\n",
261
+ " </tr>\n",
262
+ " <tr>\n",
263
+ " <th>504604</th>\n",
264
+ " <td>845167</td>\n",
265
+ " <td>296</td>\n",
266
+ " <td>Ottawa, IL</td>\n",
267
+ " <td>msa</td>\n",
268
+ " <td>IL</td>\n",
269
+ " <td>all homes</td>\n",
270
+ " <td>2023-08-31</td>\n",
271
+ " <td>0.971893</td>\n",
272
+ " <td>NaN</td>\n",
273
+ " <td>NaN</td>\n",
274
+ " <td>0.541090</td>\n",
275
+ " <td>125089.0</td>\n",
276
+ " <td>0.602041</td>\n",
277
+ " <td>131833.0</td>\n",
278
+ " <td>0.987383</td>\n",
279
+ " <td>0.294778</td>\n",
280
+ " <td>NaN</td>\n",
281
+ " <td>0.959261</td>\n",
282
+ " <td>0.294778</td>\n",
283
+ " </tr>\n",
284
+ " <tr>\n",
285
+ " <th>504605</th>\n",
286
+ " <td>845167</td>\n",
287
+ " <td>296</td>\n",
288
+ " <td>Ottawa, IL</td>\n",
289
+ " <td>msa</td>\n",
290
+ " <td>IL</td>\n",
291
+ " <td>all homes</td>\n",
292
+ " <td>2023-09-30</td>\n",
293
+ " <td>0.968028</td>\n",
294
+ " <td>NaN</td>\n",
295
+ " <td>NaN</td>\n",
296
+ " <td>0.531140</td>\n",
297
+ " <td>127199.0</td>\n",
298
+ " <td>0.500000</td>\n",
299
+ " <td>132333.0</td>\n",
300
+ " <td>0.991072</td>\n",
301
+ " <td>0.285128</td>\n",
302
+ " <td>NaN</td>\n",
303
+ " <td>0.965595</td>\n",
304
+ " <td>0.285128</td>\n",
305
+ " </tr>\n",
306
+ " <tr>\n",
307
+ " <th>504606</th>\n",
308
+ " <td>845167</td>\n",
309
+ " <td>296</td>\n",
310
+ " <td>Ottawa, IL</td>\n",
311
+ " <td>msa</td>\n",
312
+ " <td>IL</td>\n",
313
+ " <td>all homes</td>\n",
314
+ " <td>2023-10-31</td>\n",
315
+ " <td>0.962485</td>\n",
316
+ " <td>NaN</td>\n",
317
+ " <td>NaN</td>\n",
318
+ " <td>0.558836</td>\n",
319
+ " <td>131159.0</td>\n",
320
+ " <td>0.574468</td>\n",
321
+ " <td>134667.0</td>\n",
322
+ " <td>0.985657</td>\n",
323
+ " <td>0.272350</td>\n",
324
+ " <td>NaN</td>\n",
325
+ " <td>0.962599</td>\n",
326
+ " <td>0.272350</td>\n",
327
+ " </tr>\n",
328
+ " <tr>\n",
329
+ " <th>504607</th>\n",
330
+ " <td>845167</td>\n",
331
+ " <td>296</td>\n",
332
+ " <td>Ottawa, IL</td>\n",
333
+ " <td>msa</td>\n",
334
+ " <td>IL</td>\n",
335
+ " <td>all homes</td>\n",
336
+ " <td>2023-11-30</td>\n",
337
+ " <td>0.967126</td>\n",
338
+ " <td>NaN</td>\n",
339
+ " <td>NaN</td>\n",
340
+ " <td>0.539226</td>\n",
341
+ " <td>129291.0</td>\n",
342
+ " <td>0.543210</td>\n",
343
+ " <td>131000.0</td>\n",
344
+ " <td>0.990886</td>\n",
345
+ " <td>0.280538</td>\n",
346
+ " <td>NaN</td>\n",
347
+ " <td>0.973184</td>\n",
348
+ " <td>0.280538</td>\n",
349
+ " </tr>\n",
350
+ " </tbody>\n",
351
+ "</table>\n",
352
+ "<p>504608 rows × 19 columns</p>\n",
353
+ "</div>"
354
+ ],
355
+ "text/plain": [
356
+ " RegionID SizeRank RegionName RegionType StateName Home Type \\\n",
357
+ "0 102001 0 United States country NaN SFR \n",
358
+ "1 102001 0 United States country NaN SFR \n",
359
+ "2 102001 0 United States country NaN SFR \n",
360
+ "3 102001 0 United States country NaN SFR \n",
361
+ "4 102001 0 United States country NaN SFR \n",
362
+ "... ... ... ... ... ... ... \n",
363
+ "504603 845167 296 Ottawa, IL msa IL all homes \n",
364
+ "504604 845167 296 Ottawa, IL msa IL all homes \n",
365
+ "504605 845167 296 Ottawa, IL msa IL all homes \n",
366
+ "504606 845167 296 Ottawa, IL msa IL all homes \n",
367
+ "504607 845167 296 Ottawa, IL msa IL all homes \n",
368
+ "\n",
369
+ " Date Mean Sale to List Ratio (Smoothed) \\\n",
370
+ "0 2008-02-02 NaN \n",
371
+ "1 2008-02-09 NaN \n",
372
+ "2 2008-02-16 NaN \n",
373
+ "3 2008-02-23 NaN \n",
374
+ "4 2008-02-29 NaN \n",
375
+ "... ... ... \n",
376
+ "504603 2023-07-31 0.976219 \n",
377
+ "504604 2023-08-31 0.971893 \n",
378
+ "504605 2023-09-30 0.968028 \n",
379
+ "504606 2023-10-31 0.962485 \n",
380
+ "504607 2023-11-30 0.967126 \n",
381
+ "\n",
382
+ " Median Sale to List Ratio Median Sale Price \\\n",
383
+ "0 NaN 172000.0 \n",
384
+ "1 NaN 165400.0 \n",
385
+ "2 NaN 168000.0 \n",
386
+ "3 NaN 165000.0 \n",
387
+ "4 NaN NaN \n",
388
+ "... ... ... \n",
389
+ "504603 NaN NaN \n",
390
+ "504604 NaN NaN \n",
391
+ "504605 NaN NaN \n",
392
+ "504606 NaN NaN \n",
393
+ "504607 NaN NaN \n",
394
+ "\n",
395
+ " % Sold Below List (Smoothed) \\\n",
396
+ "0 NaN \n",
397
+ "1 NaN \n",
398
+ "2 NaN \n",
399
+ "3 NaN \n",
400
+ "4 NaN \n",
401
+ "... ... \n",
402
+ "504603 0.554969 \n",
403
+ "504604 0.541090 \n",
404
+ "504605 0.531140 \n",
405
+ "504606 0.558836 \n",
406
+ "504607 0.539226 \n",
407
+ "\n",
408
+ " Median Sale Price (Smoothed) (Seasonally Adjusted) % Sold Below List \\\n",
409
+ "0 NaN NaN \n",
410
+ "1 NaN NaN \n",
411
+ "2 NaN NaN \n",
412
+ "3 NaN NaN \n",
413
+ "4 NaN NaN \n",
414
+ "... ... ... \n",
415
+ "504603 127574.0 0.491379 \n",
416
+ "504604 125089.0 0.602041 \n",
417
+ "504605 127199.0 0.500000 \n",
418
+ "504606 131159.0 0.574468 \n",
419
+ "504607 129291.0 0.543210 \n",
420
+ "\n",
421
+ " Median Sale Price (Smoothed) Median Sale to List Ratio (Smoothed) \\\n",
422
+ "0 NaN NaN \n",
423
+ "1 NaN NaN \n",
424
+ "2 NaN NaN \n",
425
+ "3 167600.0 NaN \n",
426
+ "4 NaN NaN \n",
427
+ "... ... ... \n",
428
+ "504603 133500.0 0.985172 \n",
429
+ "504604 131833.0 0.987383 \n",
430
+ "504605 132333.0 0.991072 \n",
431
+ "504606 134667.0 0.985657 \n",
432
+ "504607 131000.0 0.990886 \n",
433
+ "\n",
434
+ " % Sold Above List Nowcast Mean Sale to List Ratio \\\n",
435
+ "0 NaN NaN NaN \n",
436
+ "1 NaN NaN NaN \n",
437
+ "2 NaN NaN NaN \n",
438
+ "3 NaN NaN NaN \n",
439
+ "4 NaN NaN NaN \n",
440
+ "... ... ... ... \n",
441
+ "504603 0.312332 NaN 0.979227 \n",
442
+ "504604 0.294778 NaN 0.959261 \n",
443
+ "504605 0.285128 NaN 0.965595 \n",
444
+ "504606 0.272350 NaN 0.962599 \n",
445
+ "504607 0.280538 NaN 0.973184 \n",
446
+ "\n",
447
+ " % Sold Above List (Smoothed) \n",
448
+ "0 NaN \n",
449
+ "1 NaN \n",
450
+ "2 NaN \n",
451
+ "3 NaN \n",
452
+ "4 NaN \n",
453
+ "... ... \n",
454
+ "504603 0.312332 \n",
455
+ "504604 0.294778 \n",
456
+ "504605 0.285128 \n",
457
+ "504606 0.272350 \n",
458
+ "504607 0.280538 \n",
459
+ "\n",
460
+ "[504608 rows x 19 columns]"
461
+ ]
462
+ },
463
+ "execution_count": 5,
464
+ "metadata": {},
465
+ "output_type": "execute_result"
466
+ }
467
+ ],
468
+ "source": [
469
+ "# base cols RegionID,SizeRank,RegionName,RegionType,StateName\n",
470
+ "\n",
471
+ "exclude_columns = [\n",
472
+ " \"RegionID\",\n",
473
+ " \"SizeRank\",\n",
474
+ " \"RegionName\",\n",
475
+ " \"RegionType\",\n",
476
+ " \"StateName\",\n",
477
+ " \"Home Type\",\n",
478
+ "]\n",
479
+ "\n",
480
+ "data_frames = []\n",
481
+ "\n",
482
+ "for filename in os.listdir(FULL_DATA_DIR_PATH):\n",
483
+ " if filename.endswith(\".csv\"):\n",
484
+ " print(\"processing \" + filename)\n",
485
+ " cur_df = pd.read_csv(os.path.join(FULL_DATA_DIR_PATH, filename))\n",
486
+ "\n",
487
+ " # ignore monthly data for now since it is redundant\n",
488
+ " if \"monthly\" in filename:\n",
489
+ " continue\n",
490
+ "\n",
491
+ " if \"_sfrcondo_\" in filename:\n",
492
+ " cur_df[\"Home Type\"] = \"all homes\"\n",
493
+ " elif \"_sfr_\" in filename:\n",
494
+ " cur_df[\"Home Type\"] = \"SFR\"\n",
495
+ "\n",
496
+ " # Identify columns to pivot\n",
497
+ " columns_to_pivot = [col for col in cur_df.columns if col not in exclude_columns]\n",
498
+ "\n",
499
+ " smoothed = \"_sm_\" in filename\n",
500
+ " seasonally_adjusted = \"_sa_\" in filename\n",
501
+ "\n",
502
+ " if \"_median_sale_to_list_\" in filename:\n",
503
+ " col_name = \"Median Sale to List Ratio\"\n",
504
+ " if smoothed:\n",
505
+ " col_name += \" (Smoothed)\"\n",
506
+ " if seasonally_adjusted:\n",
507
+ " col_name += \" (Seasonally Adjusted)\"\n",
508
+ "\n",
509
+ " cur_df = pd.melt(\n",
510
+ " cur_df,\n",
511
+ " id_vars=exclude_columns,\n",
512
+ " value_vars=columns_to_pivot,\n",
513
+ " var_name=\"Date\",\n",
514
+ " value_name=col_name,\n",
515
+ " )\n",
516
+ "\n",
517
+ " elif \"_mean_sale_to_list_\" in filename:\n",
518
+ " col_name = \"Mean Sale to List Ratio\"\n",
519
+ " if smoothed:\n",
520
+ " col_name += \" (Smoothed)\"\n",
521
+ " if seasonally_adjusted:\n",
522
+ " col_name += \" (Seasonally Adjusted)\"\n",
523
+ "\n",
524
+ " cur_df = pd.melt(\n",
525
+ " cur_df,\n",
526
+ " id_vars=exclude_columns,\n",
527
+ " value_vars=columns_to_pivot,\n",
528
+ " var_name=\"Date\",\n",
529
+ " value_name=col_name,\n",
530
+ " )\n",
531
+ "\n",
532
+ " elif \"_median_sale_price_\" in filename:\n",
533
+ " col_name = \"Median Sale Price\"\n",
534
+ " if smoothed:\n",
535
+ " col_name += \" (Smoothed)\"\n",
536
+ " if seasonally_adjusted:\n",
537
+ " col_name += \" (Seasonally Adjusted)\"\n",
538
+ "\n",
539
+ " cur_df = pd.melt(\n",
540
+ " cur_df,\n",
541
+ " id_vars=exclude_columns,\n",
542
+ " value_vars=columns_to_pivot,\n",
543
+ " var_name=\"Date\",\n",
544
+ " value_name=col_name,\n",
545
+ " )\n",
546
+ "\n",
547
+ " elif \"_pct_sold_above_list_\" in filename:\n",
548
+ " col_name = \"% Sold Above List\"\n",
549
+ " if smoothed:\n",
550
+ " col_name += \" (Smoothed)\"\n",
551
+ " if seasonally_adjusted:\n",
552
+ " col_name += \" (Seasonally Adjusted)\"\n",
553
+ "\n",
554
+ " cur_df = pd.melt(\n",
555
+ " cur_df,\n",
556
+ " id_vars=exclude_columns,\n",
557
+ " value_vars=columns_to_pivot,\n",
558
+ " var_name=\"Date\",\n",
559
+ " value_name=col_name,\n",
560
+ " )\n",
561
+ "\n",
562
+ " elif \"_pct_sold_below_list_\" in filename:\n",
563
+ " col_name = \"% Sold Below List\"\n",
564
+ " if smoothed:\n",
565
+ " col_name += \" (Smoothed)\"\n",
566
+ " if seasonally_adjusted:\n",
567
+ " col_name += \" (Seasonally Adjusted)\"\n",
568
+ "\n",
569
+ " cur_df = pd.melt(\n",
570
+ " cur_df,\n",
571
+ " id_vars=exclude_columns,\n",
572
+ " value_vars=columns_to_pivot,\n",
573
+ " var_name=\"Date\",\n",
574
+ " value_name=col_name,\n",
575
+ " )\n",
576
+ "\n",
577
+ " elif \"_sales_count_now_\" in filename:\n",
578
+ " col_name = \"Nowcast\"\n",
579
+ " if smoothed:\n",
580
+ " col_name += \" (Smoothed)\"\n",
581
+ " if seasonally_adjusted:\n",
582
+ " col_name += \" (Seasonally Adjusted)\"\n",
583
+ "\n",
584
+ " cur_df = pd.melt(\n",
585
+ " cur_df,\n",
586
+ " id_vars=exclude_columns,\n",
587
+ " value_vars=columns_to_pivot,\n",
588
+ " var_name=\"Date\",\n",
589
+ " value_name=col_name,\n",
590
+ " )\n",
591
+ "\n",
592
+ " data_frames.append(cur_df)\n",
593
+ "\n",
594
+ "\n",
595
+ "def get_combined_df(data_frames):\n",
596
+ " combined_df = None\n",
597
+ " if len(data_frames) > 1:\n",
598
+ " # iterate over dataframes and merge or concat\n",
599
+ " combined_df = data_frames[0]\n",
600
+ " for i in range(1, len(data_frames)):\n",
601
+ " cur_df = data_frames[i]\n",
602
+ " combined_df = pd.merge(\n",
603
+ " combined_df,\n",
604
+ " cur_df,\n",
605
+ " on=[\n",
606
+ " \"RegionID\",\n",
607
+ " \"SizeRank\",\n",
608
+ " \"RegionName\",\n",
609
+ " \"RegionType\",\n",
610
+ " \"StateName\",\n",
611
+ " \"Home Type\",\n",
612
+ " \"Date\",\n",
613
+ " ],\n",
614
+ " how=\"outer\",\n",
615
+ " suffixes=(\"\", \"_\" + str(i)),\n",
616
+ " )\n",
617
+ " elif len(data_frames) == 1:\n",
618
+ " combined_df = data_frames[0]\n",
619
+ "\n",
620
+ " return combined_df\n",
621
+ "\n",
622
+ "\n",
623
+ "combined_df = get_combined_df(data_frames)\n",
624
+ "# iterate over rows of combined df and coalesce column values across columns that start with \"Median Sale Price\"\n",
625
+ "columns_to_coalesce = [\n",
626
+ " \"Mean Sale to List Ratio (Smoothed)\"\n",
627
+ " \"Median Sale to List Ratio\"\n",
628
+ " \"Median Sale Price\"\n",
629
+ " \"% Sold Below List (Smoothed)\",\n",
630
+ " \"Median Sale Price (Smoothed) (Seasonally Adjusted)\",\n",
631
+ " \"% Sold Below List\",\n",
632
+ " \"Median Sale Price (Smoothed)\",\n",
633
+ " \"Median Sale to List Ratio (Smoothed)\",\n",
634
+ " \"% Sold Above List\",\n",
635
+ " \"Nowcast\",\n",
636
+ " \"Mean Sale to List Ratio\",\n",
637
+ " \"% Sold Above List (Smoothed)\",\n",
638
+ "]\n",
639
+ "\n",
640
+ "for index, row in combined_df.iterrows():\n",
641
+ " for col in combined_df.columns:\n",
642
+ " for column_to_coalesce in columns_to_coalesce:\n",
643
+ " if column_to_coalesce in col and \"_\" in col:\n",
644
+ " if not pd.isna(row[col]):\n",
645
+ " combined_df.at[index, column_to_coalesce] = row[col]\n",
646
+ "\n",
647
+ "# remove columns with underscores\n",
648
+ "combined_df = combined_df[[col for col in combined_df.columns if \"_\" not in col]]\n",
649
+ "\n",
650
+ "combined_df"
651
+ ]
652
+ },
653
+ {
654
+ "cell_type": "code",
655
+ "execution_count": 6,
656
+ "metadata": {},
657
+ "outputs": [
658
+ {
659
+ "data": {
660
+ "text/html": [
661
+ "<div>\n",
662
+ "<style scoped>\n",
663
+ " .dataframe tbody tr th:only-of-type {\n",
664
+ " vertical-align: middle;\n",
665
+ " }\n",
666
+ "\n",
667
+ " .dataframe tbody tr th {\n",
668
+ " vertical-align: top;\n",
669
+ " }\n",
670
+ "\n",
671
+ " .dataframe thead th {\n",
672
+ " text-align: right;\n",
673
+ " }\n",
674
+ "</style>\n",
675
+ "<table border=\"1\" class=\"dataframe\">\n",
676
+ " <thead>\n",
677
+ " <tr style=\"text-align: right;\">\n",
678
+ " <th></th>\n",
679
+ " <th>Region ID</th>\n",
680
+ " <th>Size Rank</th>\n",
681
+ " <th>Region</th>\n",
682
+ " <th>Region Type</th>\n",
683
+ " <th>State</th>\n",
684
+ " <th>Home Type</th>\n",
685
+ " <th>Date</th>\n",
686
+ " <th>Mean Sale to List Ratio (Smoothed)</th>\n",
687
+ " <th>Median Sale to List Ratio</th>\n",
688
+ " <th>Median Sale Price</th>\n",
689
+ " <th>% Sold Below List (Smoothed)</th>\n",
690
+ " <th>Median Sale Price (Smoothed) (Seasonally Adjusted)</th>\n",
691
+ " <th>% Sold Below List</th>\n",
692
+ " <th>Median Sale Price (Smoothed)</th>\n",
693
+ " <th>Median Sale to List Ratio (Smoothed)</th>\n",
694
+ " <th>% Sold Above List</th>\n",
695
+ " <th>Nowcast</th>\n",
696
+ " <th>Mean Sale to List Ratio</th>\n",
697
+ " <th>% Sold Above List (Smoothed)</th>\n",
698
+ " </tr>\n",
699
+ " </thead>\n",
700
+ " <tbody>\n",
701
+ " <tr>\n",
702
+ " <th>0</th>\n",
703
+ " <td>102001</td>\n",
704
+ " <td>0</td>\n",
705
+ " <td>United States</td>\n",
706
+ " <td>country</td>\n",
707
+ " <td>NaN</td>\n",
708
+ " <td>SFR</td>\n",
709
+ " <td>2008-02-02</td>\n",
710
+ " <td>NaN</td>\n",
711
+ " <td>NaN</td>\n",
712
+ " <td>172000.0</td>\n",
713
+ " <td>NaN</td>\n",
714
+ " <td>NaN</td>\n",
715
+ " <td>NaN</td>\n",
716
+ " <td>NaN</td>\n",
717
+ " <td>NaN</td>\n",
718
+ " <td>NaN</td>\n",
719
+ " <td>NaN</td>\n",
720
+ " <td>NaN</td>\n",
721
+ " <td>NaN</td>\n",
722
+ " </tr>\n",
723
+ " <tr>\n",
724
+ " <th>1</th>\n",
725
+ " <td>102001</td>\n",
726
+ " <td>0</td>\n",
727
+ " <td>United States</td>\n",
728
+ " <td>country</td>\n",
729
+ " <td>NaN</td>\n",
730
+ " <td>SFR</td>\n",
731
+ " <td>2008-02-09</td>\n",
732
+ " <td>NaN</td>\n",
733
+ " <td>NaN</td>\n",
734
+ " <td>165400.0</td>\n",
735
+ " <td>NaN</td>\n",
736
+ " <td>NaN</td>\n",
737
+ " <td>NaN</td>\n",
738
+ " <td>NaN</td>\n",
739
+ " <td>NaN</td>\n",
740
+ " <td>NaN</td>\n",
741
+ " <td>NaN</td>\n",
742
+ " <td>NaN</td>\n",
743
+ " <td>NaN</td>\n",
744
+ " </tr>\n",
745
+ " <tr>\n",
746
+ " <th>2</th>\n",
747
+ " <td>102001</td>\n",
748
+ " <td>0</td>\n",
749
+ " <td>United States</td>\n",
750
+ " <td>country</td>\n",
751
+ " <td>NaN</td>\n",
752
+ " <td>SFR</td>\n",
753
+ " <td>2008-02-16</td>\n",
754
+ " <td>NaN</td>\n",
755
+ " <td>NaN</td>\n",
756
+ " <td>168000.0</td>\n",
757
+ " <td>NaN</td>\n",
758
+ " <td>NaN</td>\n",
759
+ " <td>NaN</td>\n",
760
+ " <td>NaN</td>\n",
761
+ " <td>NaN</td>\n",
762
+ " <td>NaN</td>\n",
763
+ " <td>NaN</td>\n",
764
+ " <td>NaN</td>\n",
765
+ " <td>NaN</td>\n",
766
+ " </tr>\n",
767
+ " <tr>\n",
768
+ " <th>3</th>\n",
769
+ " <td>102001</td>\n",
770
+ " <td>0</td>\n",
771
+ " <td>United States</td>\n",
772
+ " <td>country</td>\n",
773
+ " <td>NaN</td>\n",
774
+ " <td>SFR</td>\n",
775
+ " <td>2008-02-23</td>\n",
776
+ " <td>NaN</td>\n",
777
+ " <td>NaN</td>\n",
778
+ " <td>165000.0</td>\n",
779
+ " <td>NaN</td>\n",
780
+ " <td>NaN</td>\n",
781
+ " <td>NaN</td>\n",
782
+ " <td>167600.0</td>\n",
783
+ " <td>NaN</td>\n",
784
+ " <td>NaN</td>\n",
785
+ " <td>NaN</td>\n",
786
+ " <td>NaN</td>\n",
787
+ " <td>NaN</td>\n",
788
+ " </tr>\n",
789
+ " <tr>\n",
790
+ " <th>4</th>\n",
791
+ " <td>102001</td>\n",
792
+ " <td>0</td>\n",
793
+ " <td>United States</td>\n",
794
+ " <td>country</td>\n",
795
+ " <td>NaN</td>\n",
796
+ " <td>SFR</td>\n",
797
+ " <td>2008-02-29</td>\n",
798
+ " <td>NaN</td>\n",
799
+ " <td>NaN</td>\n",
800
+ " <td>NaN</td>\n",
801
+ " <td>NaN</td>\n",
802
+ " <td>NaN</td>\n",
803
+ " <td>NaN</td>\n",
804
+ " <td>NaN</td>\n",
805
+ " <td>NaN</td>\n",
806
+ " <td>NaN</td>\n",
807
+ " <td>NaN</td>\n",
808
+ " <td>NaN</td>\n",
809
+ " <td>NaN</td>\n",
810
+ " </tr>\n",
811
+ " <tr>\n",
812
+ " <th>...</th>\n",
813
+ " <td>...</td>\n",
814
+ " <td>...</td>\n",
815
+ " <td>...</td>\n",
816
+ " <td>...</td>\n",
817
+ " <td>...</td>\n",
818
+ " <td>...</td>\n",
819
+ " <td>...</td>\n",
820
+ " <td>...</td>\n",
821
+ " <td>...</td>\n",
822
+ " <td>...</td>\n",
823
+ " <td>...</td>\n",
824
+ " <td>...</td>\n",
825
+ " <td>...</td>\n",
826
+ " <td>...</td>\n",
827
+ " <td>...</td>\n",
828
+ " <td>...</td>\n",
829
+ " <td>...</td>\n",
830
+ " <td>...</td>\n",
831
+ " <td>...</td>\n",
832
+ " </tr>\n",
833
+ " <tr>\n",
834
+ " <th>504603</th>\n",
835
+ " <td>845167</td>\n",
836
+ " <td>296</td>\n",
837
+ " <td>Ottawa, IL</td>\n",
838
+ " <td>msa</td>\n",
839
+ " <td>IL</td>\n",
840
+ " <td>all homes</td>\n",
841
+ " <td>2023-07-31</td>\n",
842
+ " <td>0.976219</td>\n",
843
+ " <td>NaN</td>\n",
844
+ " <td>NaN</td>\n",
845
+ " <td>0.554969</td>\n",
846
+ " <td>127574.0</td>\n",
847
+ " <td>0.491379</td>\n",
848
+ " <td>133500.0</td>\n",
849
+ " <td>0.985172</td>\n",
850
+ " <td>0.312332</td>\n",
851
+ " <td>NaN</td>\n",
852
+ " <td>0.979227</td>\n",
853
+ " <td>0.312332</td>\n",
854
+ " </tr>\n",
855
+ " <tr>\n",
856
+ " <th>504604</th>\n",
857
+ " <td>845167</td>\n",
858
+ " <td>296</td>\n",
859
+ " <td>Ottawa, IL</td>\n",
860
+ " <td>msa</td>\n",
861
+ " <td>IL</td>\n",
862
+ " <td>all homes</td>\n",
863
+ " <td>2023-08-31</td>\n",
864
+ " <td>0.971893</td>\n",
865
+ " <td>NaN</td>\n",
866
+ " <td>NaN</td>\n",
867
+ " <td>0.541090</td>\n",
868
+ " <td>125089.0</td>\n",
869
+ " <td>0.602041</td>\n",
870
+ " <td>131833.0</td>\n",
871
+ " <td>0.987383</td>\n",
872
+ " <td>0.294778</td>\n",
873
+ " <td>NaN</td>\n",
874
+ " <td>0.959261</td>\n",
875
+ " <td>0.294778</td>\n",
876
+ " </tr>\n",
877
+ " <tr>\n",
878
+ " <th>504605</th>\n",
879
+ " <td>845167</td>\n",
880
+ " <td>296</td>\n",
881
+ " <td>Ottawa, IL</td>\n",
882
+ " <td>msa</td>\n",
883
+ " <td>IL</td>\n",
884
+ " <td>all homes</td>\n",
885
+ " <td>2023-09-30</td>\n",
886
+ " <td>0.968028</td>\n",
887
+ " <td>NaN</td>\n",
888
+ " <td>NaN</td>\n",
889
+ " <td>0.531140</td>\n",
890
+ " <td>127199.0</td>\n",
891
+ " <td>0.500000</td>\n",
892
+ " <td>132333.0</td>\n",
893
+ " <td>0.991072</td>\n",
894
+ " <td>0.285128</td>\n",
895
+ " <td>NaN</td>\n",
896
+ " <td>0.965595</td>\n",
897
+ " <td>0.285128</td>\n",
898
+ " </tr>\n",
899
+ " <tr>\n",
900
+ " <th>504606</th>\n",
901
+ " <td>845167</td>\n",
902
+ " <td>296</td>\n",
903
+ " <td>Ottawa, IL</td>\n",
904
+ " <td>msa</td>\n",
905
+ " <td>IL</td>\n",
906
+ " <td>all homes</td>\n",
907
+ " <td>2023-10-31</td>\n",
908
+ " <td>0.962485</td>\n",
909
+ " <td>NaN</td>\n",
910
+ " <td>NaN</td>\n",
911
+ " <td>0.558836</td>\n",
912
+ " <td>131159.0</td>\n",
913
+ " <td>0.574468</td>\n",
914
+ " <td>134667.0</td>\n",
915
+ " <td>0.985657</td>\n",
916
+ " <td>0.272350</td>\n",
917
+ " <td>NaN</td>\n",
918
+ " <td>0.962599</td>\n",
919
+ " <td>0.272350</td>\n",
920
+ " </tr>\n",
921
+ " <tr>\n",
922
+ " <th>504607</th>\n",
923
+ " <td>845167</td>\n",
924
+ " <td>296</td>\n",
925
+ " <td>Ottawa, IL</td>\n",
926
+ " <td>msa</td>\n",
927
+ " <td>IL</td>\n",
928
+ " <td>all homes</td>\n",
929
+ " <td>2023-11-30</td>\n",
930
+ " <td>0.967126</td>\n",
931
+ " <td>NaN</td>\n",
932
+ " <td>NaN</td>\n",
933
+ " <td>0.539226</td>\n",
934
+ " <td>129291.0</td>\n",
935
+ " <td>0.543210</td>\n",
936
+ " <td>131000.0</td>\n",
937
+ " <td>0.990886</td>\n",
938
+ " <td>0.280538</td>\n",
939
+ " <td>NaN</td>\n",
940
+ " <td>0.973184</td>\n",
941
+ " <td>0.280538</td>\n",
942
+ " </tr>\n",
943
+ " </tbody>\n",
944
+ "</table>\n",
945
+ "<p>504608 rows × 19 columns</p>\n",
946
+ "</div>"
947
+ ],
948
+ "text/plain": [
949
+ " Region ID Size Rank Region Region Type State Home Type \\\n",
950
+ "0 102001 0 United States country NaN SFR \n",
951
+ "1 102001 0 United States country NaN SFR \n",
952
+ "2 102001 0 United States country NaN SFR \n",
953
+ "3 102001 0 United States country NaN SFR \n",
954
+ "4 102001 0 United States country NaN SFR \n",
955
+ "... ... ... ... ... ... ... \n",
956
+ "504603 845167 296 Ottawa, IL msa IL all homes \n",
957
+ "504604 845167 296 Ottawa, IL msa IL all homes \n",
958
+ "504605 845167 296 Ottawa, IL msa IL all homes \n",
959
+ "504606 845167 296 Ottawa, IL msa IL all homes \n",
960
+ "504607 845167 296 Ottawa, IL msa IL all homes \n",
961
+ "\n",
962
+ " Date Mean Sale to List Ratio (Smoothed) \\\n",
963
+ "0 2008-02-02 NaN \n",
964
+ "1 2008-02-09 NaN \n",
965
+ "2 2008-02-16 NaN \n",
966
+ "3 2008-02-23 NaN \n",
967
+ "4 2008-02-29 NaN \n",
968
+ "... ... ... \n",
969
+ "504603 2023-07-31 0.976219 \n",
970
+ "504604 2023-08-31 0.971893 \n",
971
+ "504605 2023-09-30 0.968028 \n",
972
+ "504606 2023-10-31 0.962485 \n",
973
+ "504607 2023-11-30 0.967126 \n",
974
+ "\n",
975
+ " Median Sale to List Ratio Median Sale Price \\\n",
976
+ "0 NaN 172000.0 \n",
977
+ "1 NaN 165400.0 \n",
978
+ "2 NaN 168000.0 \n",
979
+ "3 NaN 165000.0 \n",
980
+ "4 NaN NaN \n",
981
+ "... ... ... \n",
982
+ "504603 NaN NaN \n",
983
+ "504604 NaN NaN \n",
984
+ "504605 NaN NaN \n",
985
+ "504606 NaN NaN \n",
986
+ "504607 NaN NaN \n",
987
+ "\n",
988
+ " % Sold Below List (Smoothed) \\\n",
989
+ "0 NaN \n",
990
+ "1 NaN \n",
991
+ "2 NaN \n",
992
+ "3 NaN \n",
993
+ "4 NaN \n",
994
+ "... ... \n",
995
+ "504603 0.554969 \n",
996
+ "504604 0.541090 \n",
997
+ "504605 0.531140 \n",
998
+ "504606 0.558836 \n",
999
+ "504607 0.539226 \n",
1000
+ "\n",
1001
+ " Median Sale Price (Smoothed) (Seasonally Adjusted) % Sold Below List \\\n",
1002
+ "0 NaN NaN \n",
1003
+ "1 NaN NaN \n",
1004
+ "2 NaN NaN \n",
1005
+ "3 NaN NaN \n",
1006
+ "4 NaN NaN \n",
1007
+ "... ... ... \n",
1008
+ "504603 127574.0 0.491379 \n",
1009
+ "504604 125089.0 0.602041 \n",
1010
+ "504605 127199.0 0.500000 \n",
1011
+ "504606 131159.0 0.574468 \n",
1012
+ "504607 129291.0 0.543210 \n",
1013
+ "\n",
1014
+ " Median Sale Price (Smoothed) Median Sale to List Ratio (Smoothed) \\\n",
1015
+ "0 NaN NaN \n",
1016
+ "1 NaN NaN \n",
1017
+ "2 NaN NaN \n",
1018
+ "3 167600.0 NaN \n",
1019
+ "4 NaN NaN \n",
1020
+ "... ... ... \n",
1021
+ "504603 133500.0 0.985172 \n",
1022
+ "504604 131833.0 0.987383 \n",
1023
+ "504605 132333.0 0.991072 \n",
1024
+ "504606 134667.0 0.985657 \n",
1025
+ "504607 131000.0 0.990886 \n",
1026
+ "\n",
1027
+ " % Sold Above List Nowcast Mean Sale to List Ratio \\\n",
1028
+ "0 NaN NaN NaN \n",
1029
+ "1 NaN NaN NaN \n",
1030
+ "2 NaN NaN NaN \n",
1031
+ "3 NaN NaN NaN \n",
1032
+ "4 NaN NaN NaN \n",
1033
+ "... ... ... ... \n",
1034
+ "504603 0.312332 NaN 0.979227 \n",
1035
+ "504604 0.294778 NaN 0.959261 \n",
1036
+ "504605 0.285128 NaN 0.965595 \n",
1037
+ "504606 0.272350 NaN 0.962599 \n",
1038
+ "504607 0.280538 NaN 0.973184 \n",
1039
+ "\n",
1040
+ " % Sold Above List (Smoothed) \n",
1041
+ "0 NaN \n",
1042
+ "1 NaN \n",
1043
+ "2 NaN \n",
1044
+ "3 NaN \n",
1045
+ "4 NaN \n",
1046
+ "... ... \n",
1047
+ "504603 0.312332 \n",
1048
+ "504604 0.294778 \n",
1049
+ "504605 0.285128 \n",
1050
+ "504606 0.272350 \n",
1051
+ "504607 0.280538 \n",
1052
+ "\n",
1053
+ "[504608 rows x 19 columns]"
1054
+ ]
1055
+ },
1056
+ "execution_count": 6,
1057
+ "metadata": {},
1058
+ "output_type": "execute_result"
1059
+ }
1060
+ ],
1061
+ "source": [
1062
+ "final_df = combined_df\n",
1063
+ "final_df = final_df.rename(\n",
1064
+ " columns={\n",
1065
+ " \"RegionID\": \"Region ID\",\n",
1066
+ " \"SizeRank\": \"Size Rank\",\n",
1067
+ " \"RegionName\": \"Region\",\n",
1068
+ " \"RegionType\": \"Region Type\",\n",
1069
+ " \"StateName\": \"State\",\n",
1070
+ " }\n",
1071
+ ")\n",
1072
+ "\n",
1073
+ "final_df.sort_values(by=[\"Region ID\", \"Home Type\", \"Date\"])"
1074
+ ]
1075
+ },
1076
+ {
1077
+ "cell_type": "code",
1078
+ "execution_count": 7,
1079
+ "metadata": {},
1080
+ "outputs": [],
1081
+ "source": [
1082
+ "if not os.path.exists(FULL_PROCESSED_DIR_PATH):\n",
1083
+ " os.makedirs(FULL_PROCESSED_DIR_PATH)\n",
1084
+ "\n",
1085
+ "final_df.to_json(FULL_PROCESSED_DIR_PATH + \"final.jsonl\", orient=\"records\", lines=True)"
1086
+ ]
1087
+ }
1088
+ ],
1089
+ "metadata": {
1090
+ "kernelspec": {
1091
+ "display_name": "Python 3",
1092
+ "language": "python",
1093
+ "name": "python3"
1094
+ },
1095
+ "language_info": {
1096
+ "codemirror_mode": {
1097
+ "name": "ipython",
1098
+ "version": 3
1099
+ },
1100
+ "file_extension": ".py",
1101
+ "mimetype": "text/x-python",
1102
+ "name": "python",
1103
+ "nbconvert_exporter": "python",
1104
+ "pygments_lexer": "ipython3",
1105
+ "version": "3.12.2"
1106
+ }
1107
+ },
1108
+ "nbformat": 4,
1109
+ "nbformat_minor": 2
1110
+ }
tester.ipynb CHANGED
@@ -2,18 +2,9 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 2,
6
  "metadata": {},
7
- "outputs": [
8
- {
9
- "name": "stderr",
10
- "output_type": "stream",
11
- "text": [
12
- "/Users/misikoff/opt/anaconda3/envs/sta663/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
13
- " from .autonotebook import tqdm as notebook_tqdm\n"
14
- ]
15
- }
16
- ],
17
  "source": [
18
  "# !pip install datasets\n",
19
  "\n",
@@ -22,30 +13,55 @@
22
  },
23
  {
24
  "cell_type": "code",
25
- "execution_count": 4,
26
  "metadata": {},
27
  "outputs": [
28
  {
29
- "name": "stderr",
30
  "output_type": "stream",
31
  "text": [
32
- "Downloading builder script: 100%|██████████| 18.5k/18.5k [00:00<00:00, 11.3MB/s]\n",
33
- "Downloading data: 100%|██████████| 20.4M/20.4M [00:00<00:00, 33.6MB/s]\n",
34
- "Generating train split: 96012 examples [00:02, 46188.04 examples/s]\n",
35
- "Generating validation split: 96012 examples [00:02, 47013.79 examples/s]\n",
36
- "Generating test split: 96012 examples [00:02, 46947.45 examples/s]\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  ]
38
  }
39
  ],
40
  "source": [
41
- "configs = [\"home_value_forecasts\", \"new_constructions\", \"for_sale_listings\", \"rentals\"]\n",
42
- "\n",
43
- "dataset = load_dataset(\"misikoff/zillow\", \"rentals\", trust_remote_code=True)"
 
 
 
 
 
 
 
 
 
44
  ]
45
  },
46
  {
47
  "cell_type": "code",
48
- "execution_count": 27,
49
  "metadata": {},
50
  "outputs": [
51
  {
@@ -57,13 +73,12 @@
57
  " 'Region Type': 'country',\n",
58
  " 'State': None,\n",
59
  " 'Home Type': 'SFR',\n",
60
- " 'Date': '2018-01-31',\n",
61
- " 'Sale Price': 309000.0,\n",
62
- " 'Sale Price per Sqft': 137.41232299804688,\n",
63
- " 'Count': 33940}"
64
  ]
65
  },
66
- "execution_count": 27,
67
  "metadata": {},
68
  "output_type": "execute_result"
69
  }
@@ -74,7 +89,7 @@
74
  },
75
  {
76
  "cell_type": "code",
77
- "execution_count": 28,
78
  "metadata": {},
79
  "outputs": [],
80
  "source": [
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 10,
6
  "metadata": {},
7
+ "outputs": [],
 
 
 
 
 
 
 
 
 
8
  "source": [
9
  "# !pip install datasets\n",
10
  "\n",
 
13
  },
14
  {
15
  "cell_type": "code",
16
+ "execution_count": 11,
17
  "metadata": {},
18
  "outputs": [
19
  {
20
+ "name": "stdout",
21
  "output_type": "stream",
22
  "text": [
23
+ "home_value_forecasts\n",
24
+ "new_constructions\n",
25
+ "for_sale_listings\n",
26
+ "rentals\n",
27
+ "sales\n",
28
+ "home_values\n"
29
+ ]
30
+ },
31
+ {
32
+ "ename": "ValueError",
33
+ "evalue": "BuilderConfig 'home_values' not found. Available: ['home_value_forecasts', 'new_constructions', 'for_sale_listings', 'rentals', 'sales']",
34
+ "output_type": "error",
35
+ "traceback": [
36
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
37
+ "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
38
+ "Cell \u001b[0;32mIn[11], line 12\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m config \u001b[38;5;129;01min\u001b[39;00m configs:\n\u001b[1;32m 11\u001b[0m \u001b[38;5;28mprint\u001b[39m(config)\n\u001b[0;32m---> 12\u001b[0m dataset \u001b[38;5;241m=\u001b[39m \u001b[43mload_dataset\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmisikoff/zillow\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtrust_remote_code\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n",
39
+ "File \u001b[0;32m~/opt/anaconda3/envs/sta663/lib/python3.12/site-packages/datasets/load.py:2548\u001b[0m, in \u001b[0;36mload_dataset\u001b[0;34m(path, name, data_dir, data_files, split, cache_dir, features, download_config, download_mode, verification_mode, ignore_verifications, keep_in_memory, save_infos, revision, token, use_auth_token, task, streaming, num_proc, storage_options, trust_remote_code, **config_kwargs)\u001b[0m\n\u001b[1;32m 2543\u001b[0m verification_mode \u001b[38;5;241m=\u001b[39m VerificationMode(\n\u001b[1;32m 2544\u001b[0m (verification_mode \u001b[38;5;129;01mor\u001b[39;00m VerificationMode\u001b[38;5;241m.\u001b[39mBASIC_CHECKS) \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m save_infos \u001b[38;5;28;01melse\u001b[39;00m VerificationMode\u001b[38;5;241m.\u001b[39mALL_CHECKS\n\u001b[1;32m 2545\u001b[0m )\n\u001b[1;32m 2547\u001b[0m \u001b[38;5;66;03m# Create a dataset builder\u001b[39;00m\n\u001b[0;32m-> 2548\u001b[0m builder_instance \u001b[38;5;241m=\u001b[39m \u001b[43mload_dataset_builder\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 2549\u001b[0m \u001b[43m \u001b[49m\u001b[43mpath\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpath\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2550\u001b[0m \u001b[43m \u001b[49m\u001b[43mname\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2551\u001b[0m \u001b[43m \u001b[49m\u001b[43mdata_dir\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdata_dir\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2552\u001b[0m \u001b[43m \u001b[49m\u001b[43mdata_files\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdata_files\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2553\u001b[0m \u001b[43m \u001b[49m\u001b[43mcache_dir\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcache_dir\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2554\u001b[0m \u001b[43m \u001b[49m\u001b[43mfeatures\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfeatures\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2555\u001b[0m \u001b[43m \u001b[49m\u001b[43mdownload_config\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdownload_config\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2556\u001b[0m \u001b[43m \u001b[49m\u001b[43mdownload_mode\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdownload_mode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2557\u001b[0m \u001b[43m \u001b[49m\u001b[43mrevision\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrevision\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2558\u001b[0m \u001b[43m \u001b[49m\u001b[43mtoken\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtoken\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2559\u001b[0m \u001b[43m \u001b[49m\u001b[43mstorage_options\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstorage_options\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2560\u001b[0m \u001b[43m \u001b[49m\u001b[43mtrust_remote_code\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtrust_remote_code\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2561\u001b[0m \u001b[43m \u001b[49m\u001b[43m_require_default_config_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mname\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mis\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 2562\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mconfig_kwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2563\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2565\u001b[0m \u001b[38;5;66;03m# Return iterable dataset in case of streaming\u001b[39;00m\n\u001b[1;32m 2566\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m streaming:\n",
40
+ "File \u001b[0;32m~/opt/anaconda3/envs/sta663/lib/python3.12/site-packages/datasets/load.py:2257\u001b[0m, in \u001b[0;36mload_dataset_builder\u001b[0;34m(path, name, data_dir, data_files, cache_dir, features, download_config, download_mode, revision, token, use_auth_token, storage_options, trust_remote_code, _require_default_config_name, **config_kwargs)\u001b[0m\n\u001b[1;32m 2255\u001b[0m builder_cls \u001b[38;5;241m=\u001b[39m get_dataset_builder_class(dataset_module, dataset_name\u001b[38;5;241m=\u001b[39mdataset_name)\n\u001b[1;32m 2256\u001b[0m \u001b[38;5;66;03m# Instantiate the dataset builder\u001b[39;00m\n\u001b[0;32m-> 2257\u001b[0m builder_instance: DatasetBuilder \u001b[38;5;241m=\u001b[39m \u001b[43mbuilder_cls\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 2258\u001b[0m \u001b[43m \u001b[49m\u001b[43mcache_dir\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcache_dir\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2259\u001b[0m \u001b[43m \u001b[49m\u001b[43mdataset_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdataset_name\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2260\u001b[0m \u001b[43m \u001b[49m\u001b[43mconfig_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig_name\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2261\u001b[0m \u001b[43m \u001b[49m\u001b[43mdata_dir\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdata_dir\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2262\u001b[0m \u001b[43m \u001b[49m\u001b[43mdata_files\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdata_files\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2263\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mhash\u001b[39;49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdataset_module\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhash\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2264\u001b[0m \u001b[43m \u001b[49m\u001b[43minfo\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43minfo\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2265\u001b[0m \u001b[43m \u001b[49m\u001b[43mfeatures\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfeatures\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2266\u001b[0m \u001b[43m \u001b[49m\u001b[43mtoken\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtoken\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2267\u001b[0m \u001b[43m \u001b[49m\u001b[43mstorage_options\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstorage_options\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2268\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mbuilder_kwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2269\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mconfig_kwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2270\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2271\u001b[0m builder_instance\u001b[38;5;241m.\u001b[39m_use_legacy_cache_dir_if_possible(dataset_module)\n\u001b[1;32m 2273\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m builder_instance\n",
41
+ "File \u001b[0;32m~/opt/anaconda3/envs/sta663/lib/python3.12/site-packages/datasets/builder.py:371\u001b[0m, in \u001b[0;36mDatasetBuilder.__init__\u001b[0;34m(self, cache_dir, dataset_name, config_name, hash, base_path, info, features, token, use_auth_token, repo_id, data_files, data_dir, storage_options, writer_batch_size, name, **config_kwargs)\u001b[0m\n\u001b[1;32m 369\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m data_dir \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 370\u001b[0m config_kwargs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdata_dir\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m data_dir\n\u001b[0;32m--> 371\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconfig, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconfig_id \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_create_builder_config\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 372\u001b[0m \u001b[43m \u001b[49m\u001b[43mconfig_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig_name\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 373\u001b[0m \u001b[43m \u001b[49m\u001b[43mcustom_features\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfeatures\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 374\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mconfig_kwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 375\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 377\u001b[0m \u001b[38;5;66;03m# prepare info: DatasetInfo are a standardized dataclass across all datasets\u001b[39;00m\n\u001b[1;32m 378\u001b[0m \u001b[38;5;66;03m# Prefill datasetinfo\u001b[39;00m\n\u001b[1;32m 379\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m info \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 380\u001b[0m \u001b[38;5;66;03m# TODO FOR PACKAGED MODULES IT IMPORTS DATA FROM src/packaged_modules which doesn't make sense\u001b[39;00m\n",
42
+ "File \u001b[0;32m~/opt/anaconda3/envs/sta663/lib/python3.12/site-packages/datasets/builder.py:592\u001b[0m, in \u001b[0;36mDatasetBuilder._create_builder_config\u001b[0;34m(self, config_name, custom_features, **config_kwargs)\u001b[0m\n\u001b[1;32m 590\u001b[0m builder_config \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mbuilder_configs\u001b[38;5;241m.\u001b[39mget(config_name)\n\u001b[1;32m 591\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m builder_config \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mBUILDER_CONFIGS:\n\u001b[0;32m--> 592\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 593\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mBuilderConfig \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mconfig_name\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m not found. Available: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mlist\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mbuilder_configs\u001b[38;5;241m.\u001b[39mkeys())\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 594\u001b[0m )\n\u001b[1;32m 596\u001b[0m \u001b[38;5;66;03m# if not using an existing config, then create a new config on the fly\u001b[39;00m\n\u001b[1;32m 597\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m builder_config:\n",
43
+ "\u001b[0;31mValueError\u001b[0m: BuilderConfig 'home_values' not found. Available: ['home_value_forecasts', 'new_constructions', 'for_sale_listings', 'rentals', 'sales']"
44
  ]
45
  }
46
  ],
47
  "source": [
48
+ "configs = [\n",
49
+ " \"home_value_forecasts\",\n",
50
+ " \"new_constructions\",\n",
51
+ " \"for_sale_listings\",\n",
52
+ " \"rentals\",\n",
53
+ " \"sales\",\n",
54
+ " \"home_values\",\n",
55
+ " \"days_on_market\",\n",
56
+ "]\n",
57
+ "for config in configs:\n",
58
+ " print(config)\n",
59
+ " dataset = load_dataset(\"misikoff/zillow\", config, trust_remote_code=True)"
60
  ]
61
  },
62
  {
63
  "cell_type": "code",
64
+ "execution_count": 7,
65
  "metadata": {},
66
  "outputs": [
67
  {
 
73
  " 'Region Type': 'country',\n",
74
  " 'State': None,\n",
75
  " 'Home Type': 'SFR',\n",
76
+ " 'Date': '2015-01-31',\n",
77
+ " 'Rent (Smoothed)': 1251.1195068359375,\n",
78
+ " 'Rent (Smoothed) (Seasonally Adjusted)': 1253.3807373046875}"
 
79
  ]
80
  },
81
+ "execution_count": 7,
82
  "metadata": {},
83
  "output_type": "execute_result"
84
  }
 
89
  },
90
  {
91
  "cell_type": "code",
92
+ "execution_count": 8,
93
  "metadata": {},
94
  "outputs": [],
95
  "source": [
zillow.py CHANGED
@@ -15,7 +15,6 @@
15
  """TODO: Add a description here."""
16
 
17
 
18
- # import csv
19
  import json
20
  import os
21
 
@@ -44,14 +43,6 @@ _HOMEPAGE = ""
44
  # TODO: Add the licence for the dataset here if you can find it
45
  _LICENSE = ""
46
 
47
- # TODO: Add link to the official dataset URLs here
48
- # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
49
- # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
50
- # _URLS = {
51
- # "home_value_forecasts": "https://files.zillowstatic.com/research/public_csvs/zhvf_growth/Metro_zhvf_growth_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv",
52
- # # "second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip",
53
- # }
54
-
55
 
56
  # TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
57
  class NewDataset(datasets.GeneratorBasedBuilder):
@@ -59,17 +50,6 @@ class NewDataset(datasets.GeneratorBasedBuilder):
59
 
60
  VERSION = datasets.Version("1.1.0")
61
 
62
- # This is an example of a dataset with multiple configurations.
63
- # If you don't want/need to define several sub-sets in your dataset,
64
- # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
65
-
66
- # If you need to make complex sub-parts in the datasets with configurable options
67
- # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
68
- # BUILDER_CONFIG_CLASS = MyBuilderConfig
69
-
70
- # You will be able to load one or the other configurations in the following list with
71
- # data = datasets.load_dataset('my_dataset', 'home_value_forecasts')
72
- # data = datasets.load_dataset('my_dataset', 'second_domain')
73
  BUILDER_CONFIGS = [
74
  datasets.BuilderConfig(
75
  name="home_value_forecasts",
@@ -91,15 +71,27 @@ class NewDataset(datasets.GeneratorBasedBuilder):
91
  version=VERSION,
92
  description="This part of my dataset covers a second domain",
93
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  ]
95
 
96
- DEFAULT_CONFIG_NAME = "home_value_forecasts" # It's not mandatory to have a default configuration. Just use one if it make sense.
97
 
98
  def _info(self):
99
- # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
100
- if (
101
- self.config.name == "home_value_forecasts"
102
- ): # This is the name of the configuration selected in BUILDER_CONFIGS above
103
  features = datasets.Features(
104
  {
105
  "RegionID": datasets.Value(dtype="string", id="RegionID"),
@@ -129,7 +121,6 @@ class NewDataset(datasets.GeneratorBasedBuilder):
129
  "Year Over Year % (Raw)": datasets.Value(
130
  dtype="float32", id="Month Over Month % (Smoothed)"
131
  ),
132
- # These are the features of your dataset like images, labels ...
133
  }
134
  )
135
  elif self.config.name == "new_constructions":
@@ -147,7 +138,6 @@ class NewDataset(datasets.GeneratorBasedBuilder):
147
  dtype="float32", id="Sale Price per Sqft"
148
  ),
149
  "Count": datasets.Value(dtype="int32", id="Count"),
150
- # These are the features of your dataset like images, labels ...
151
  }
152
  )
153
  elif self.config.name == "for_sale_listings":
@@ -174,7 +164,6 @@ class NewDataset(datasets.GeneratorBasedBuilder):
174
  dtype="int32", id="New Pending (Smoothed)"
175
  ),
176
  "New Pending": datasets.Value(dtype="int32", id="New Pending"),
177
- # These are the features of your dataset like images, labels ...
178
  }
179
  )
180
  elif self.config.name == "rentals":
@@ -193,18 +182,83 @@ class NewDataset(datasets.GeneratorBasedBuilder):
193
  "Rent (Smoothed) (Seasonally Adjusted)": datasets.Value(
194
  dtype="float32", id="Rent (Smoothed) (Seasonally Adjusted)"
195
  ),
196
- # These are the features of your dataset like images, labels ...
197
  }
198
  )
199
- # else: # This is an example to show how to have different features for "home_value_forecasts" and "second_domain"
200
- # features = datasets.Features(
201
- # {
202
- # "sentence": datasets.Value("string"),
203
- # "option2": datasets.Value("string"),
204
- # "second_domain_answer": datasets.Value("string"),
205
- # # These are the features of your dataset like images, labels ...
206
- # }
207
- # )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  return datasets.DatasetInfo(
209
  # This is the description that will appear on the datasets page.
210
  description=_DESCRIPTION,
@@ -222,20 +276,7 @@ class NewDataset(datasets.GeneratorBasedBuilder):
222
  )
223
 
224
  def _split_generators(self, dl_manager):
225
- # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
226
- # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
227
-
228
- # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
229
- # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
230
- # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
231
-
232
- # urls = _URLS[self.config.name]
233
- # data_dir = dl_manager.download_and_extract(urls)
234
- # file_train = dl_manager.download(os.path.join('./data/home_value_forecasts', "Metro_zhvf_growth_uc_sfrcondo_tier_0.33_0.67_month.csv"))
235
  file_path = os.path.join("processed", self.config.name, "final.jsonl")
236
- # print('*********************')
237
- # print(file_path)
238
-
239
  file_train = dl_manager.download(file_path)
240
  # file_test = dl_manager.download(os.path.join(self.config.name, "test.csv"))
241
  # file_eval = dl_manager.download(os.path.join(self.config.name, "valid.csv"))
@@ -244,37 +285,35 @@ class NewDataset(datasets.GeneratorBasedBuilder):
244
  name=datasets.Split.TRAIN,
245
  # These kwargs will be passed to _generate_examples
246
  gen_kwargs={
247
- "filepath": file_train, # os.path.join(data_dir, "train.jsonl"),
248
  "split": "train",
249
  },
250
  ),
251
- datasets.SplitGenerator(
252
- name=datasets.Split.VALIDATION,
253
- # These kwargs will be passed to _generate_examples
254
- gen_kwargs={
255
- "filepath": file_train, # os.path.join(data_dir, "dev.jsonl"),
256
- "split": "dev",
257
- },
258
- ),
259
- datasets.SplitGenerator(
260
- name=datasets.Split.TEST,
261
- # These kwargs will be passed to _generate_examples
262
- gen_kwargs={
263
- "filepath": file_train, # os.path.join(data_dir, "test.jsonl"),
264
- "split": "test",
265
- },
266
- ),
267
  ]
268
 
269
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
270
  def _generate_examples(self, filepath, split):
271
- # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
272
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
273
  with open(filepath, encoding="utf-8") as f:
274
  for key, row in enumerate(f):
275
  data = json.loads(row)
276
  if self.config.name == "home_value_forecasts":
277
- # Yields examples as (key, example) tuples
278
  yield key, {
279
  "RegionID": data["RegionID"],
280
  "SizeRank": data["SizeRank"],
@@ -299,10 +338,8 @@ class NewDataset(datasets.GeneratorBasedBuilder):
299
  "Quarter Over Quarter % (Raw)"
300
  ],
301
  "Year Over Year % (Raw)": data["Year Over Year % (Raw)"],
302
- # "answer": "" if split == "test" else data["answer"],
303
  }
304
  elif self.config.name == "new_constructions":
305
- # Yields examples as (key, example) tuples
306
  yield key, {
307
  "Region ID": data["Region ID"],
308
  "Size Rank": data["Size Rank"],
@@ -314,10 +351,8 @@ class NewDataset(datasets.GeneratorBasedBuilder):
314
  "Sale Price": data["Sale Price"],
315
  "Sale Price per Sqft": data["Sale Price per Sqft"],
316
  "Count": data["Count"],
317
- # "answer": "" if split == "test" else data["answer"],
318
  }
319
  elif self.config.name == "for_sale_listings":
320
- # Yields examples as (key, example) tuples
321
  yield key, {
322
  "Region ID": data["Region ID"],
323
  "Size Rank": data["Size Rank"],
@@ -334,10 +369,8 @@ class NewDataset(datasets.GeneratorBasedBuilder):
334
  "New Listings (Smoothed)": data["New Listings (Smoothed)"],
335
  "New Pending (Smoothed)": data["New Pending (Smoothed)"],
336
  "New Pending": data["New Pending"],
337
- # "answer": "" if split == "test" else data["answer"],
338
  }
339
  elif self.config.name == "rentals":
340
- # Yields examples as (key, example) tuples
341
  yield key, {
342
  "Region ID": data["Region ID"],
343
  "Size Rank": data["Size Rank"],
@@ -350,13 +383,59 @@ class NewDataset(datasets.GeneratorBasedBuilder):
350
  "Rent (Smoothed) (Seasonally Adjusted)": data[
351
  "Rent (Smoothed) (Seasonally Adjusted)"
352
  ],
353
- # "answer": "" if split == "test" else data["answer"],
354
  }
355
- # else:
356
- # yield key, {
357
- # "sentence": data["sentence"],
358
- # "option2": data["option2"],
359
- # "second_domain_answer": (
360
- # "" if split == "test" else data["second_domain_answer"]
361
- # ),
362
- # }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  """TODO: Add a description here."""
16
 
17
 
 
18
  import json
19
  import os
20
 
 
43
  # TODO: Add the licence for the dataset here if you can find it
44
  _LICENSE = ""
45
 
 
 
 
 
 
 
 
 
46
 
47
  # TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
48
  class NewDataset(datasets.GeneratorBasedBuilder):
 
50
 
51
  VERSION = datasets.Version("1.1.0")
52
 
 
 
 
 
 
 
 
 
 
 
 
53
  BUILDER_CONFIGS = [
54
  datasets.BuilderConfig(
55
  name="home_value_forecasts",
 
71
  version=VERSION,
72
  description="This part of my dataset covers a second domain",
73
  ),
74
+ datasets.BuilderConfig(
75
+ name="sales",
76
+ version=VERSION,
77
+ description="This part of my dataset covers a second domain",
78
+ ),
79
+ datasets.BuilderConfig(
80
+ name="home_values",
81
+ version=VERSION,
82
+ description="This part of my dataset covers a second domain",
83
+ ),
84
+ datasets.BuilderConfig(
85
+ name="days_on_market",
86
+ version=VERSION,
87
+ description="This part of my dataset covers a second domain",
88
+ ),
89
  ]
90
 
91
+ DEFAULT_CONFIG_NAME = "home_value_forecasts"
92
 
93
  def _info(self):
94
+ if self.config.name == "home_value_forecasts":
 
 
 
95
  features = datasets.Features(
96
  {
97
  "RegionID": datasets.Value(dtype="string", id="RegionID"),
 
121
  "Year Over Year % (Raw)": datasets.Value(
122
  dtype="float32", id="Month Over Month % (Smoothed)"
123
  ),
 
124
  }
125
  )
126
  elif self.config.name == "new_constructions":
 
138
  dtype="float32", id="Sale Price per Sqft"
139
  ),
140
  "Count": datasets.Value(dtype="int32", id="Count"),
 
141
  }
142
  )
143
  elif self.config.name == "for_sale_listings":
 
164
  dtype="int32", id="New Pending (Smoothed)"
165
  ),
166
  "New Pending": datasets.Value(dtype="int32", id="New Pending"),
 
167
  }
168
  )
169
  elif self.config.name == "rentals":
 
182
  "Rent (Smoothed) (Seasonally Adjusted)": datasets.Value(
183
  dtype="float32", id="Rent (Smoothed) (Seasonally Adjusted)"
184
  ),
 
185
  }
186
  )
187
+ elif self.config.name == "sales":
188
+ features = datasets.Features(
189
+ {
190
+ "Region ID": datasets.Value(dtype="string", id="Region ID"),
191
+ "Size Rank": datasets.Value(dtype="int32", id="Size Rank"),
192
+ "Region": datasets.Value(dtype="string", id="Region"),
193
+ "Region Type": datasets.Value(dtype="string", id="Region Type"),
194
+ "State": datasets.Value(dtype="string", id="State"),
195
+ "Home Type": datasets.Value(dtype="string", id="Home Type"),
196
+ "Date": datasets.Value(dtype="string", id="Date"),
197
+ "Mean Sale to List Ratio (Smoothed)": datasets.Value(
198
+ dtype="float32", id="Mean Sale to List Ratio (Smoothed)"
199
+ ),
200
+ "Median Sale to List Ratio": datasets.Value(
201
+ dtype="float32", id="Median Sale to List Ratio"
202
+ ),
203
+ "Median Sale Price": datasets.Value(
204
+ dtype="float32", id="Median Sale Price"
205
+ ),
206
+ "% Sold Below List (Smoothed)": datasets.Value(
207
+ dtype="float32", id="% Sold Below List (Smoothed)"
208
+ ),
209
+ "Median Sale Price (Smoothed) (Seasonally Adjusted)": datasets.Value(
210
+ dtype="float32",
211
+ id="Median Sale Price (Smoothed) (Seasonally Adjusted)",
212
+ ),
213
+ "% Sold Below List": datasets.Value(
214
+ dtype="float32", id="% Sold Below List"
215
+ ),
216
+ "Median Sale Price (Smoothed)": datasets.Value(
217
+ dtype="float32", id="Median Sale Price (Smoothed)"
218
+ ),
219
+ "Median Sale to List Ratio (Smoothed)": datasets.Value(
220
+ dtype="float32", id="Median Sale to List Ratio (Smoothed)"
221
+ ),
222
+ "% Sold Above List": datasets.Value(
223
+ dtype="float32", id="% Sold Above List"
224
+ ),
225
+ "Nowcast": datasets.Value(dtype="float32", id="Nowcast"),
226
+ "Mean Sale to List Ratio": datasets.Value(
227
+ dtype="float32", id="Mean Sale to List Ratio"
228
+ ),
229
+ "% Sold Above List (Smoothed)": datasets.Value(
230
+ dtype="float32", id="% Sold Above List (Smoothed)"
231
+ ),
232
+ }
233
+ )
234
+ elif self.config.name == "home_values":
235
+ features = datasets.Features(
236
+ {
237
+ "Region ID": datasets.Value(dtype="string", id="Region ID"),
238
+ "Size Rank": datasets.Value(dtype="int32", id="Size Rank"),
239
+ "Region": datasets.Value(dtype="string", id="Region"),
240
+ "Region Type": datasets.Value(dtype="string", id="Region Type"),
241
+ "State": datasets.Value(dtype="string", id="State"),
242
+ "Home Type": datasets.Value(dtype="string", id="Home Type"),
243
+ "Date": datasets.Value(dtype="string", id="Date"),
244
+ "Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)": datasets.Value(
245
+ dtype="float32",
246
+ id="Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)",
247
+ ),
248
+ "Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted)": datasets.Value(
249
+ dtype="float32",
250
+ id="Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted)",
251
+ ),
252
+ "Top Tier ZHVI (Smoothed) (Seasonally Adjusted)": datasets.Value(
253
+ dtype="float32",
254
+ id="Top Tier ZHVI (Smoothed) (Seasonally Adjusted)",
255
+ ),
256
+ "ZHVI": datasets.Value(dtype="float32", id="ZHVI"),
257
+ "Mid Tier ZHVI": datasets.Value(
258
+ dtype="float32", id="Mid Tier ZHVI"
259
+ ),
260
+ }
261
+ )
262
  return datasets.DatasetInfo(
263
  # This is the description that will appear on the datasets page.
264
  description=_DESCRIPTION,
 
276
  )
277
 
278
  def _split_generators(self, dl_manager):
 
 
 
 
 
 
 
 
 
 
279
  file_path = os.path.join("processed", self.config.name, "final.jsonl")
 
 
 
280
  file_train = dl_manager.download(file_path)
281
  # file_test = dl_manager.download(os.path.join(self.config.name, "test.csv"))
282
  # file_eval = dl_manager.download(os.path.join(self.config.name, "valid.csv"))
 
285
  name=datasets.Split.TRAIN,
286
  # These kwargs will be passed to _generate_examples
287
  gen_kwargs={
288
+ "filepath": file_train,
289
  "split": "train",
290
  },
291
  ),
292
+ # datasets.SplitGenerator(
293
+ # name=datasets.Split.VALIDATION,
294
+ # # These kwargs will be passed to _generate_examples
295
+ # gen_kwargs={
296
+ # "filepath": file_train, # os.path.join(data_dir, "dev.jsonl"),
297
+ # "split": "dev",
298
+ # },
299
+ # ),
300
+ # datasets.SplitGenerator(
301
+ # name=datasets.Split.TEST,
302
+ # # These kwargs will be passed to _generate_examples
303
+ # gen_kwargs={
304
+ # "filepath": file_train, # os.path.join(data_dir, "test.jsonl"),
305
+ # "split": "test",
306
+ # },
307
+ # ),
308
  ]
309
 
310
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
311
  def _generate_examples(self, filepath, split):
 
312
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
313
  with open(filepath, encoding="utf-8") as f:
314
  for key, row in enumerate(f):
315
  data = json.loads(row)
316
  if self.config.name == "home_value_forecasts":
 
317
  yield key, {
318
  "RegionID": data["RegionID"],
319
  "SizeRank": data["SizeRank"],
 
338
  "Quarter Over Quarter % (Raw)"
339
  ],
340
  "Year Over Year % (Raw)": data["Year Over Year % (Raw)"],
 
341
  }
342
  elif self.config.name == "new_constructions":
 
343
  yield key, {
344
  "Region ID": data["Region ID"],
345
  "Size Rank": data["Size Rank"],
 
351
  "Sale Price": data["Sale Price"],
352
  "Sale Price per Sqft": data["Sale Price per Sqft"],
353
  "Count": data["Count"],
 
354
  }
355
  elif self.config.name == "for_sale_listings":
 
356
  yield key, {
357
  "Region ID": data["Region ID"],
358
  "Size Rank": data["Size Rank"],
 
369
  "New Listings (Smoothed)": data["New Listings (Smoothed)"],
370
  "New Pending (Smoothed)": data["New Pending (Smoothed)"],
371
  "New Pending": data["New Pending"],
 
372
  }
373
  elif self.config.name == "rentals":
 
374
  yield key, {
375
  "Region ID": data["Region ID"],
376
  "Size Rank": data["Size Rank"],
 
383
  "Rent (Smoothed) (Seasonally Adjusted)": data[
384
  "Rent (Smoothed) (Seasonally Adjusted)"
385
  ],
 
386
  }
387
+ elif self.config.name == "sales":
388
+ yield key, {
389
+ "Region ID": data["Region ID"],
390
+ "Size Rank": data["Size Rank"],
391
+ "Region": data["Region"],
392
+ "Region Type": data["Region Type"],
393
+ "State": data["State"],
394
+ "Home Type": data["Home Type"],
395
+ "Date": data["Date"],
396
+ "Mean Sale to List Ratio (Smoothed)": data[
397
+ "Mean Sale to List Ratio (Smoothed)"
398
+ ],
399
+ "Median Sale to List Ratio": data["Median Sale to List Ratio"],
400
+ "Median Sale Price": data["Median Sale Price"],
401
+ "% Sold Below List (Smoothed)": data[
402
+ "% Sold Below List (Smoothed)"
403
+ ],
404
+ "Median Sale Price (Smoothed) (Seasonally Adjusted)": data[
405
+ "Median Sale Price (Smoothed) (Seasonally Adjusted)"
406
+ ],
407
+ "% Sold Below List": data["% Sold Below List"],
408
+ "Median Sale Price (Smoothed)": data[
409
+ "Median Sale Price (Smoothed)"
410
+ ],
411
+ "Median Sale to List Ratio (Smoothed)": data[
412
+ "Median Sale to List Ratio (Smoothed)"
413
+ ],
414
+ "% Sold Above List": data["% Sold Above List"],
415
+ "Nowcast": data["Nowcast"],
416
+ "Mean Sale to List Ratio": data["Mean Sale to List Ratio"],
417
+ "% Sold Above List (Smoothed)": data[
418
+ "% Sold Above List (Smoothed)"
419
+ ],
420
+ }
421
+ elif self.config.name == "home_values":
422
+ yield key, {
423
+ "Region ID": data["Region ID"],
424
+ "Size Rank": data["Size Rank"],
425
+ "Region": data["Region"],
426
+ "Region Type": data["Region Type"],
427
+ "State": data["State"],
428
+ "Home Type": data["Home Type"],
429
+ "Date": data["Date"],
430
+ "Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)": data[
431
+ "Mid Tier ZHVI (Smoothed) (Seasonally Adjusted)"
432
+ ],
433
+ "Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted)": data[
434
+ "Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted)"
435
+ ],
436
+ "Top Tier ZHVI (Smoothed) (Seasonally Adjusted)": data[
437
+ "Top Tier ZHVI (Smoothed) (Seasonally Adjusted)"
438
+ ],
439
+ "ZHVI": data["ZHVI"],
440
+ "Mid Tier ZHVI": data["Mid Tier ZHVI"],
441
+ }