File size: 29,689 Bytes
55b505d
 
 
 
 
 
 
 
 
 
 
 
 
 
b35ac2b
55b505d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53fe7a6
55b505d
53fe7a6
 
 
 
 
 
 
 
 
 
 
55b505d
 
 
 
 
53fe7a6
 
 
 
55b505d
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
 
55b505d
 
 
53fe7a6
 
 
 
55b505d
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
 
55b505d
 
 
53fe7a6
 
 
 
55b505d
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
 
55b505d
 
 
53fe7a6
 
 
 
55b505d
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
 
55b505d
 
 
53fe7a6
 
 
 
55b505d
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
 
55b505d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53fe7a6
 
 
 
55b505d
 
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55b505d
 
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55b505d
 
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55b505d
 
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55b505d
 
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55b505d
 
 
53fe7a6
55b505d
 
 
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55b505d
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
55b505d
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
55b505d
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
55b505d
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
55b505d
53fe7a6
55b505d
 
b35ac2b
55b505d
 
 
 
 
 
53fe7a6
55b505d
 
 
 
 
53fe7a6
55b505d
 
 
 
 
53fe7a6
55b505d
 
53fe7a6
55b505d
 
 
 
 
 
 
 
 
 
 
53fe7a6
55b505d
 
 
 
 
53fe7a6
55b505d
 
53fe7a6
55b505d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53fe7a6
 
 
b35ac2b
53fe7a6
b35ac2b
53fe7a6
 
 
 
 
 
b35ac2b
53fe7a6
 
 
 
 
 
 
 
 
 
 
 
 
b35ac2b
 
 
 
53fe7a6
 
 
 
 
 
 
b35ac2b
 
 
 
53fe7a6
b35ac2b
 
53fe7a6
 
 
 
 
 
 
 
b35ac2b
53fe7a6
 
 
 
 
b35ac2b
53fe7a6
b35ac2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53fe7a6
b35ac2b
 
 
53fe7a6
 
b35ac2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53fe7a6
55b505d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# import json as pandas\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Region ID</th>\n",
       "      <th>Size Rank</th>\n",
       "      <th>Region</th>\n",
       "      <th>Region Type</th>\n",
       "      <th>State</th>\n",
       "      <th>Home Type</th>\n",
       "      <th>Date</th>\n",
       "      <th>Median Sale to List Ratio</th>\n",
       "      <th>Median Sale Price</th>\n",
       "      <th>Median Sale Price (Smoothed) (Seasonally Adjusted)</th>\n",
       "      <th>Median Sale Price (Smoothed)</th>\n",
       "      <th>% Sold Below List (Smoothed)</th>\n",
       "      <th>Median Sale to List Ratio (Smoothed)</th>\n",
       "      <th>% Sold Above List</th>\n",
       "      <th>Mean Sale to List Ratio (Smoothed)</th>\n",
       "      <th>Mean Sale to List Ratio</th>\n",
       "      <th>% Sold Below List</th>\n",
       "      <th>% Sold Above List (Smoothed)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>102001</td>\n",
       "      <td>0</td>\n",
       "      <td>United States</td>\n",
       "      <td>country</td>\n",
       "      <td>None</td>\n",
       "      <td>SFR</td>\n",
       "      <td>2008-02-02</td>\n",
       "      <td>NaN</td>\n",
       "      <td>172000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>102001</td>\n",
       "      <td>0</td>\n",
       "      <td>United States</td>\n",
       "      <td>country</td>\n",
       "      <td>None</td>\n",
       "      <td>SFR</td>\n",
       "      <td>2008-02-09</td>\n",
       "      <td>NaN</td>\n",
       "      <td>165400.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>102001</td>\n",
       "      <td>0</td>\n",
       "      <td>United States</td>\n",
       "      <td>country</td>\n",
       "      <td>None</td>\n",
       "      <td>SFR</td>\n",
       "      <td>2008-02-16</td>\n",
       "      <td>NaN</td>\n",
       "      <td>168000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>102001</td>\n",
       "      <td>0</td>\n",
       "      <td>United States</td>\n",
       "      <td>country</td>\n",
       "      <td>None</td>\n",
       "      <td>SFR</td>\n",
       "      <td>2008-02-23</td>\n",
       "      <td>NaN</td>\n",
       "      <td>167600.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>167600.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>102001</td>\n",
       "      <td>0</td>\n",
       "      <td>United States</td>\n",
       "      <td>country</td>\n",
       "      <td>None</td>\n",
       "      <td>SFR</td>\n",
       "      <td>2008-03-01</td>\n",
       "      <td>NaN</td>\n",
       "      <td>168100.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>168100.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>255019</th>\n",
       "      <td>845160</td>\n",
       "      <td>198</td>\n",
       "      <td>Prescott Valley, AZ</td>\n",
       "      <td>msa</td>\n",
       "      <td>AZ</td>\n",
       "      <td>all homes</td>\n",
       "      <td>2023-11-11</td>\n",
       "      <td>0.985132</td>\n",
       "      <td>515000.0</td>\n",
       "      <td>480020.0</td>\n",
       "      <td>480020.0</td>\n",
       "      <td>0.651221</td>\n",
       "      <td>0.982460</td>\n",
       "      <td>0.080000</td>\n",
       "      <td>0.978546</td>\n",
       "      <td>0.983288</td>\n",
       "      <td>0.680000</td>\n",
       "      <td>0.119711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>255020</th>\n",
       "      <td>845160</td>\n",
       "      <td>198</td>\n",
       "      <td>Prescott Valley, AZ</td>\n",
       "      <td>msa</td>\n",
       "      <td>AZ</td>\n",
       "      <td>all homes</td>\n",
       "      <td>2023-11-18</td>\n",
       "      <td>0.972559</td>\n",
       "      <td>510000.0</td>\n",
       "      <td>476901.0</td>\n",
       "      <td>476901.0</td>\n",
       "      <td>0.659583</td>\n",
       "      <td>0.980362</td>\n",
       "      <td>0.142857</td>\n",
       "      <td>0.972912</td>\n",
       "      <td>0.958341</td>\n",
       "      <td>0.625000</td>\n",
       "      <td>0.120214</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>255021</th>\n",
       "      <td>845160</td>\n",
       "      <td>198</td>\n",
       "      <td>Prescott Valley, AZ</td>\n",
       "      <td>msa</td>\n",
       "      <td>AZ</td>\n",
       "      <td>all homes</td>\n",
       "      <td>2023-11-25</td>\n",
       "      <td>0.979644</td>\n",
       "      <td>484500.0</td>\n",
       "      <td>496540.0</td>\n",
       "      <td>496540.0</td>\n",
       "      <td>0.669387</td>\n",
       "      <td>0.979179</td>\n",
       "      <td>0.088235</td>\n",
       "      <td>0.971177</td>\n",
       "      <td>0.973797</td>\n",
       "      <td>0.705882</td>\n",
       "      <td>0.107185</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>255022</th>\n",
       "      <td>845160</td>\n",
       "      <td>198</td>\n",
       "      <td>Prescott Valley, AZ</td>\n",
       "      <td>msa</td>\n",
       "      <td>AZ</td>\n",
       "      <td>all homes</td>\n",
       "      <td>2023-12-02</td>\n",
       "      <td>0.978261</td>\n",
       "      <td>538000.0</td>\n",
       "      <td>510491.0</td>\n",
       "      <td>510491.0</td>\n",
       "      <td>0.678777</td>\n",
       "      <td>0.978899</td>\n",
       "      <td>0.126761</td>\n",
       "      <td>0.970576</td>\n",
       "      <td>0.966876</td>\n",
       "      <td>0.704225</td>\n",
       "      <td>0.109463</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>255023</th>\n",
       "      <td>845160</td>\n",
       "      <td>198</td>\n",
       "      <td>Prescott Valley, AZ</td>\n",
       "      <td>msa</td>\n",
       "      <td>AZ</td>\n",
       "      <td>all homes</td>\n",
       "      <td>2023-12-09</td>\n",
       "      <td>0.981498</td>\n",
       "      <td>485000.0</td>\n",
       "      <td>503423.0</td>\n",
       "      <td>503423.0</td>\n",
       "      <td>0.658777</td>\n",
       "      <td>0.977990</td>\n",
       "      <td>0.100000</td>\n",
       "      <td>0.970073</td>\n",
       "      <td>0.981278</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>0.114463</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>255024 rows Γ— 18 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        Region ID  Size Rank               Region Region Type State  \\\n",
       "0          102001          0        United States     country  None   \n",
       "1          102001          0        United States     country  None   \n",
       "2          102001          0        United States     country  None   \n",
       "3          102001          0        United States     country  None   \n",
       "4          102001          0        United States     country  None   \n",
       "...           ...        ...                  ...         ...   ...   \n",
       "255019     845160        198  Prescott Valley, AZ         msa    AZ   \n",
       "255020     845160        198  Prescott Valley, AZ         msa    AZ   \n",
       "255021     845160        198  Prescott Valley, AZ         msa    AZ   \n",
       "255022     845160        198  Prescott Valley, AZ         msa    AZ   \n",
       "255023     845160        198  Prescott Valley, AZ         msa    AZ   \n",
       "\n",
       "        Home Type       Date  Median Sale to List Ratio  Median Sale Price  \\\n",
       "0             SFR 2008-02-02                        NaN           172000.0   \n",
       "1             SFR 2008-02-09                        NaN           165400.0   \n",
       "2             SFR 2008-02-16                        NaN           168000.0   \n",
       "3             SFR 2008-02-23                        NaN           167600.0   \n",
       "4             SFR 2008-03-01                        NaN           168100.0   \n",
       "...           ...        ...                        ...                ...   \n",
       "255019  all homes 2023-11-11                   0.985132           515000.0   \n",
       "255020  all homes 2023-11-18                   0.972559           510000.0   \n",
       "255021  all homes 2023-11-25                   0.979644           484500.0   \n",
       "255022  all homes 2023-12-02                   0.978261           538000.0   \n",
       "255023  all homes 2023-12-09                   0.981498           485000.0   \n",
       "\n",
       "        Median Sale Price (Smoothed) (Seasonally Adjusted)  \\\n",
       "0                                                     NaN    \n",
       "1                                                     NaN    \n",
       "2                                                     NaN    \n",
       "3                                                     NaN    \n",
       "4                                                     NaN    \n",
       "...                                                   ...    \n",
       "255019                                           480020.0    \n",
       "255020                                           476901.0    \n",
       "255021                                           496540.0    \n",
       "255022                                           510491.0    \n",
       "255023                                           503423.0    \n",
       "\n",
       "        Median Sale Price (Smoothed)  % Sold Below List (Smoothed)  \\\n",
       "0                                NaN                           NaN   \n",
       "1                                NaN                           NaN   \n",
       "2                                NaN                           NaN   \n",
       "3                           167600.0                           NaN   \n",
       "4                           168100.0                           NaN   \n",
       "...                              ...                           ...   \n",
       "255019                      480020.0                      0.651221   \n",
       "255020                      476901.0                      0.659583   \n",
       "255021                      496540.0                      0.669387   \n",
       "255022                      510491.0                      0.678777   \n",
       "255023                      503423.0                      0.658777   \n",
       "\n",
       "        Median Sale to List Ratio (Smoothed)  % Sold Above List  \\\n",
       "0                                        NaN                NaN   \n",
       "1                                        NaN                NaN   \n",
       "2                                        NaN                NaN   \n",
       "3                                        NaN                NaN   \n",
       "4                                        NaN                NaN   \n",
       "...                                      ...                ...   \n",
       "255019                              0.982460           0.080000   \n",
       "255020                              0.980362           0.142857   \n",
       "255021                              0.979179           0.088235   \n",
       "255022                              0.978899           0.126761   \n",
       "255023                              0.977990           0.100000   \n",
       "\n",
       "        Mean Sale to List Ratio (Smoothed)  Mean Sale to List Ratio  \\\n",
       "0                                      NaN                      NaN   \n",
       "1                                      NaN                      NaN   \n",
       "2                                      NaN                      NaN   \n",
       "3                                      NaN                      NaN   \n",
       "4                                      NaN                      NaN   \n",
       "...                                    ...                      ...   \n",
       "255019                            0.978546                 0.983288   \n",
       "255020                            0.972912                 0.958341   \n",
       "255021                            0.971177                 0.973797   \n",
       "255022                            0.970576                 0.966876   \n",
       "255023                            0.970073                 0.981278   \n",
       "\n",
       "        % Sold Below List  % Sold Above List (Smoothed)  \n",
       "0                     NaN                           NaN  \n",
       "1                     NaN                           NaN  \n",
       "2                     NaN                           NaN  \n",
       "3                     NaN                           NaN  \n",
       "4                     NaN                           NaN  \n",
       "...                   ...                           ...  \n",
       "255019           0.680000                      0.119711  \n",
       "255020           0.625000                      0.120214  \n",
       "255021           0.705882                      0.107185  \n",
       "255022           0.704225                      0.109463  \n",
       "255023           0.600000                      0.114463  \n",
       "\n",
       "[255024 rows x 18 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# read the data\n",
    "x = pd.read_json(\"processed/sales/final5.jsonl\", lines=True)\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['country', 'msa'], dtype=object)"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# get unique values for column\n",
    "x[\"Region Type\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['SFR', 'all homes'], dtype=object)"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[\"Home Type\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['1-Bedroom', '2-Bedrooms', '3-Bedrooms', '4-Bedrooms',\n",
       "       '5+-Bedrooms', 'All Bedrooms'], dtype=object)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[\"Bedroom Count\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "from datasets import load_dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sales\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading builder script: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 26.8k/26.8k [00:00<00:00, 14.2MB/s]\n",
      "Downloading readme: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 21.7k/21.7k [00:00<00:00, 3.80MB/s]\n",
      "Downloading data: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 139M/139M [00:04<00:00, 32.2MB/s] \n",
      "Generating train split: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 255024/255024 [00:10<00:00, 24068.33 examples/s]\n"
     ]
    }
   ],
   "source": [
    "dataset_dict = {}\n",
    "\n",
    "configs = [\n",
    "    # \"home_values_forecasts\",\n",
    "    # \"new_construction\",\n",
    "    # \"for_sale_listings\",\n",
    "    # \"rentals\",\n",
    "    \"sales\",\n",
    "    # \"home_values\",\n",
    "    # \"days_on_market\",\n",
    "]\n",
    "for config in configs:\n",
    "    print(config)\n",
    "    dataset_dict[config] = load_dataset(\n",
    "        \"misikoff/zillow\",\n",
    "        config,\n",
    "        trust_remote_code=True,\n",
    "        download_mode=\"force_redownload\",\n",
    "        cache_dir=\"./cache\",\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "ename": "ArrowInvalid",
     "evalue": "Not a Feather V1 or Arrow IPC file",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mArrowInvalid\u001b[0m                              Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[40], line 4\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpyarrow\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mpa\u001b[39;00m\n\u001b[0;32m----> 4\u001b[0m df \u001b[38;5;241m=\u001b[39m \u001b[43mpd\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_feather\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m      5\u001b[0m \u001b[43m    \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m~/desktop/cache/misikoff___zillow/sales/1.1.0/c70d9545e9cef7612b795e19b5393a565f297e17856ab372df6f4026ecc498ae/zillow-train.arrow\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\n\u001b[1;32m      6\u001b[0m \u001b[43m)\u001b[49m\n\u001b[1;32m      7\u001b[0m df\n",
      "File \u001b[0;32m~/opt/anaconda3/envs/sta663/lib/python3.12/site-packages/pandas/io/feather_format.py:124\u001b[0m, in \u001b[0;36mread_feather\u001b[0;34m(path, columns, use_threads, storage_options, dtype_backend)\u001b[0m\n\u001b[1;32m    120\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m get_handle(\n\u001b[1;32m    121\u001b[0m     path, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mrb\u001b[39m\u001b[38;5;124m\"\u001b[39m, storage_options\u001b[38;5;241m=\u001b[39mstorage_options, is_text\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m\n\u001b[1;32m    122\u001b[0m ) \u001b[38;5;28;01mas\u001b[39;00m handles:\n\u001b[1;32m    123\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m dtype_backend \u001b[38;5;129;01mis\u001b[39;00m lib\u001b[38;5;241m.\u001b[39mno_default \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m using_pyarrow_string_dtype():\n\u001b[0;32m--> 124\u001b[0m         \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfeather\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_feather\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    125\u001b[0m \u001b[43m            \u001b[49m\u001b[43mhandles\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhandle\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcolumns\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcolumns\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43muse_threads\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mbool\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43muse_threads\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    126\u001b[0m \u001b[43m        \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    128\u001b[0m     pa_table \u001b[38;5;241m=\u001b[39m feather\u001b[38;5;241m.\u001b[39mread_table(\n\u001b[1;32m    129\u001b[0m         handles\u001b[38;5;241m.\u001b[39mhandle, columns\u001b[38;5;241m=\u001b[39mcolumns, use_threads\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mbool\u001b[39m(use_threads)\n\u001b[1;32m    130\u001b[0m     )\n\u001b[1;32m    132\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m dtype_backend \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnumpy_nullable\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n",
      "File \u001b[0;32m~/opt/anaconda3/envs/sta663/lib/python3.12/site-packages/pyarrow/feather.py:226\u001b[0m, in \u001b[0;36mread_feather\u001b[0;34m(source, columns, use_threads, memory_map, **kwargs)\u001b[0m\n\u001b[1;32m    199\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mread_feather\u001b[39m(source, columns\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, use_threads\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m,\n\u001b[1;32m    200\u001b[0m                  memory_map\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m    201\u001b[0m \u001b[38;5;250m    \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m    202\u001b[0m \u001b[38;5;124;03m    Read a pandas.DataFrame from Feather format. To read as pyarrow.Table use\u001b[39;00m\n\u001b[1;32m    203\u001b[0m \u001b[38;5;124;03m    feather.read_table.\u001b[39;00m\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m    224\u001b[0m \u001b[38;5;124;03m        The contents of the Feather file as a pandas.DataFrame\u001b[39;00m\n\u001b[1;32m    225\u001b[0m \u001b[38;5;124;03m    \"\"\"\u001b[39;00m\n\u001b[0;32m--> 226\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m (\u001b[43mread_table\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    227\u001b[0m \u001b[43m        \u001b[49m\u001b[43msource\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcolumns\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcolumns\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmemory_map\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmemory_map\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    228\u001b[0m \u001b[43m        \u001b[49m\u001b[43muse_threads\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43muse_threads\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mto_pandas(use_threads\u001b[38;5;241m=\u001b[39muse_threads, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs))\n",
      "File \u001b[0;32m~/opt/anaconda3/envs/sta663/lib/python3.12/site-packages/pyarrow/feather.py:252\u001b[0m, in \u001b[0;36mread_table\u001b[0;34m(source, columns, memory_map, use_threads)\u001b[0m\n\u001b[1;32m    231\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mread_table\u001b[39m(source, columns\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, memory_map\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m, use_threads\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m):\n\u001b[1;32m    232\u001b[0m \u001b[38;5;250m    \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m    233\u001b[0m \u001b[38;5;124;03m    Read a pyarrow.Table from Feather format\u001b[39;00m\n\u001b[1;32m    234\u001b[0m \n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m    250\u001b[0m \u001b[38;5;124;03m        The contents of the Feather file as a pyarrow.Table\u001b[39;00m\n\u001b[1;32m    251\u001b[0m \u001b[38;5;124;03m    \"\"\"\u001b[39;00m\n\u001b[0;32m--> 252\u001b[0m     reader \u001b[38;5;241m=\u001b[39m \u001b[43m_feather\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mFeatherReader\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    253\u001b[0m \u001b[43m        \u001b[49m\u001b[43msource\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43muse_memory_map\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmemory_map\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43muse_threads\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43muse_threads\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    255\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m columns \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m    256\u001b[0m         \u001b[38;5;28;01mreturn\u001b[39;00m reader\u001b[38;5;241m.\u001b[39mread()\n",
      "File \u001b[0;32m~/opt/anaconda3/envs/sta663/lib/python3.12/site-packages/pyarrow/_feather.pyx:79\u001b[0m, in \u001b[0;36mpyarrow._feather.FeatherReader.__cinit__\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32m~/opt/anaconda3/envs/sta663/lib/python3.12/site-packages/pyarrow/error.pxi:154\u001b[0m, in \u001b[0;36mpyarrow.lib.pyarrow_internal_check_status\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32m~/opt/anaconda3/envs/sta663/lib/python3.12/site-packages/pyarrow/error.pxi:91\u001b[0m, in \u001b[0;36mpyarrow.lib.check_status\u001b[0;34m()\u001b[0m\n",
      "\u001b[0;31mArrowInvalid\u001b[0m: Not a Feather V1 or Arrow IPC file"
     ]
    }
   ],
   "source": [
    "import pyarrow as pa\n",
    "\n",
    "\n",
    "df = pd.read_feather(\n",
    "    \"~/desktop/cache/misikoff___zillow/sales/1.1.0/c70d9545e9cef7612b795e19b5393a565f297e17856ab372df6f4026ecc498ae/zillow-train.arrow\"\n",
    ")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Creating parquet from Arrow format: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 256/256 [00:00<00:00, 738.39ba/s]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "27088039"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataset_dict[config][\"train\"].to_parquet(\"test-sales.parquet\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Region ID': '102001',\n",
       " 'Size Rank': 0,\n",
       " 'Region': 'United States',\n",
       " 'Region Type': 0,\n",
       " 'State': None,\n",
       " 'Home Type': 0,\n",
       " 'Date': datetime.datetime(2008, 2, 2, 0, 0),\n",
       " 'Mean Sale to List Ratio (Smoothed)': None,\n",
       " 'Median Sale to List Ratio': None,\n",
       " 'Median Sale Price': 172000.0,\n",
       " 'Median Sale Price (Smoothed) (Seasonally Adjusted)': None,\n",
       " 'Median Sale Price (Smoothed)': None,\n",
       " 'Median Sale to List Ratio (Smoothed)': None,\n",
       " '% Sold Below List': None,\n",
       " '% Sold Below List (Smoothed)': None,\n",
       " '% Sold Above List': None,\n",
       " '% Sold Above List (Smoothed)': None,\n",
       " 'Mean Sale to List Ratio': None}"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gen = iter(dataset_dict[config][\"train\"])\n",
    "next(gen)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "sta663",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}