{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# import json as pandas\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Region IDSize RankRegionRegion TypeStateHome TypeDateMedian Sale to List RatioMedian Sale PriceMedian Sale Price (Smoothed) (Seasonally Adjusted)Median Sale Price (Smoothed)% Sold Below List (Smoothed)Median Sale to List Ratio (Smoothed)% Sold Above ListMean Sale to List Ratio (Smoothed)Mean Sale to List Ratio% Sold Below List% Sold Above List (Smoothed)
01020010United StatescountryNoneSFR2008-02-02NaN172000.0NaNNaNNaNNaNNaNNaNNaNNaNNaN
11020010United StatescountryNoneSFR2008-02-09NaN165400.0NaNNaNNaNNaNNaNNaNNaNNaNNaN
21020010United StatescountryNoneSFR2008-02-16NaN168000.0NaNNaNNaNNaNNaNNaNNaNNaNNaN
31020010United StatescountryNoneSFR2008-02-23NaN167600.0NaN167600.0NaNNaNNaNNaNNaNNaNNaN
41020010United StatescountryNoneSFR2008-03-01NaN168100.0NaN168100.0NaNNaNNaNNaNNaNNaNNaN
.........................................................
255019845160198Prescott Valley, AZmsaAZall homes2023-11-110.985132515000.0480020.0480020.00.6512210.9824600.0800000.9785460.9832880.6800000.119711
255020845160198Prescott Valley, AZmsaAZall homes2023-11-180.972559510000.0476901.0476901.00.6595830.9803620.1428570.9729120.9583410.6250000.120214
255021845160198Prescott Valley, AZmsaAZall homes2023-11-250.979644484500.0496540.0496540.00.6693870.9791790.0882350.9711770.9737970.7058820.107185
255022845160198Prescott Valley, AZmsaAZall homes2023-12-020.978261538000.0510491.0510491.00.6787770.9788990.1267610.9705760.9668760.7042250.109463
255023845160198Prescott Valley, AZmsaAZall homes2023-12-090.981498485000.0503423.0503423.00.6587770.9779900.1000000.9700730.9812780.6000000.114463
\n", "

255024 rows × 18 columns

\n", "
" ], "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": 30, "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": 34, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/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", " from .autonotebook import tqdm as notebook_tqdm\n" ] } ], "source": [ "from datasets import load_dataset" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "home_values_forecasts\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading builder script: 100%|██████████| 26.8k/26.8k [00:00<00:00, 15.9MB/s]\n", "Downloading readme: 100%|██████████| 13.2k/13.2k [00:00<00:00, 19.4MB/s]\n", "Downloading data: 100%|██████████| 14.1M/14.1M [00:01<00:00, 11.0MB/s]\n", "Generating train split: 31854 examples [00:01, 27592.53 examples/s]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "new_construction\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading builder script: 100%|██████████| 26.8k/26.8k [00:00<00:00, 7.13MB/s]\n", "Downloading readme: 100%|██████████| 13.2k/13.2k [00:00<00:00, 10.4MB/s]\n", "Downloading data: 100%|██████████| 10.9M/10.9M [00:01<00:00, 5.63MB/s]\n", "Generating train split: 49487 examples [00:01, 42744.19 examples/s]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "for_sale_listings\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading builder script: 100%|██████████| 26.8k/26.8k [00:00<00:00, 5.22MB/s]\n", "Downloading readme: 100%|██████████| 13.2k/13.2k [00:00<00:00, 4.72MB/s]\n", "Downloading data: 100%|██████████| 180M/180M [00:06<00:00, 28.9MB/s] \n", "Generating train split: 578653 examples [00:16, 34651.20 examples/s]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "rentals\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading builder script: 100%|██████████| 26.8k/26.8k [00:00<00:00, 6.18MB/s]\n", "Downloading readme: 100%|██████████| 13.2k/13.2k [00:00<00:00, 13.3MB/s]\n", "Downloading data: 100%|██████████| 446M/446M [00:11<00:00, 38.2MB/s] \n", "Generating train split: 1258740 examples [00:28, 44189.96 examples/s]\n" ] }, { "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, 12.7MB/s]\n", "Downloading readme: 100%|██████████| 13.2k/13.2k [00:00<00:00, 13.5MB/s]\n", "Downloading data: 100%|██████████| 139M/139M [00:04<00:00, 34.2MB/s] \n", "Generating train split: 255024 examples [00:09, 26686.54 examples/s]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "home_values\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading builder script: 100%|██████████| 26.8k/26.8k [00:00<00:00, 2.18MB/s]\n", "Downloading readme: 100%|██████████| 13.2k/13.2k [00:00<00:00, 8.86MB/s]\n", "Downloading data: 100%|██████████| 42.1M/42.1M [00:01<00:00, 32.4MB/s]\n", "Generating train split: 117912 examples [00:03, 37382.19 examples/s]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "days_on_market\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading builder script: 100%|██████████| 26.8k/26.8k [00:00<00:00, 12.7MB/s]\n", "Downloading readme: 100%|██████████| 13.2k/13.2k [00:00<00:00, 8.86MB/s]\n", "Downloading data: 100%|██████████| 233M/233M [00:06<00:00, 34.9MB/s] \n", "Generating train split: 586714 examples [00:17, 34104.98 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=\"~/desktop/cache\",\n", " )" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df = pd.read_feather(\n", " \"~/desktop/cache/misikoff___zillow/sales/1.1.0/c70d9545e9cef7612b795e19b5393a565f297e17856ab372df6f4026ecc498ae/zillow-train.arrow\"\n", ")" ] } ], "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 }