{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import os\n", "\n", "from helpers import (\n", " get_data_path_for_config,\n", " get_combined_df,\n", " save_final_df_as_jsonl,\n", " handle_slug_column_mappings,\n", " set_home_type,\n", ")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "CONFIG_NAME = \"sales\"" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "processing Metro_mean_sale_to_list_uc_sfrcondo_sm_month.csv\n", "processing Metro_median_sale_to_list_uc_sfrcondo_week.csv\n", "processing Metro_median_sale_price_uc_sfr_week.csv\n", "processing Metro_pct_sold_below_list_uc_sfrcondo_sm_month.csv\n", "processing Metro_median_sale_price_uc_sfr_sm_sa_week.csv\n", "processing Metro_pct_sold_below_list_uc_sfrcondo_month.csv\n", "processing Metro_median_sale_price_uc_sfrcondo_sm_week.csv\n", "processing Metro_pct_sold_below_list_uc_sfrcondo_sm_week.csv\n", "processing Metro_median_sale_price_uc_sfr_month.csv\n", "processing Metro_median_sale_to_list_uc_sfrcondo_sm_month.csv\n", "processing Metro_pct_sold_above_list_uc_sfrcondo_month.csv\n", "processing Metro_median_sale_to_list_uc_sfrcondo_sm_week.csv\n", "processing Metro_median_sale_price_uc_sfrcondo_sm_sa_month.csv\n", "processing Metro_sales_count_now_uc_sfrcondo_month.csv\n", "processing Metro_pct_sold_above_list_uc_sfrcondo_week.csv\n", "processing Metro_mean_sale_to_list_uc_sfrcondo_sm_week.csv\n", "processing Metro_median_sale_price_uc_sfrcondo_sm_month.csv\n", "processing Metro_mean_sale_to_list_uc_sfrcondo_week.csv\n", "processing Metro_median_sale_price_uc_sfr_sm_month.csv\n", "processing Metro_median_sale_to_list_uc_sfrcondo_month.csv\n", "processing Metro_median_sale_price_uc_sfrcondo_sm_sa_week.csv\n", "processing Metro_pct_sold_below_list_uc_sfrcondo_week.csv\n", "processing Metro_median_sale_price_uc_sfrcondo_week.csv\n", "processing Metro_mean_sale_to_list_uc_sfrcondo_month.csv\n", "processing Metro_pct_sold_above_list_uc_sfrcondo_sm_week.csv\n", "processing Metro_median_sale_price_uc_sfr_sm_week.csv\n", "processing Metro_median_sale_price_uc_sfrcondo_month.csv\n", "processing Metro_pct_sold_above_list_uc_sfrcondo_sm_month.csv\n" ] }, { "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", "
RegionIDSizeRankRegionNameRegionTypeStateNameHome 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 StatescountryNaNSFR2008-02-02NaN172000.0NaNNaNNaNNaNNaNNaNNaNNaNNaN
11020010United StatescountryNaNSFR2008-02-09NaN165400.0NaNNaNNaNNaNNaNNaNNaNNaNNaN
21020010United StatescountryNaNSFR2008-02-16NaN168000.0NaNNaNNaNNaNNaNNaNNaNNaNNaN
31020010United StatescountryNaNSFR2008-02-23NaN167600.0NaN167600.0NaNNaNNaNNaNNaNNaNNaN
41020010United StatescountryNaNSFR2008-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": [ " RegionID SizeRank RegionName RegionType StateName \\\n", "0 102001 0 United States country NaN \n", "1 102001 0 United States country NaN \n", "2 102001 0 United States country NaN \n", "3 102001 0 United States country NaN \n", "4 102001 0 United States country NaN \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": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_frames = []\n", "\n", "exclude_columns = [\n", " \"RegionID\",\n", " \"SizeRank\",\n", " \"RegionName\",\n", " \"RegionType\",\n", " \"StateName\",\n", " \"Home Type\",\n", "]\n", "\n", "slug_column_mappings = {\n", " \"_median_sale_to_list_\": \"Median Sale to List Ratio\",\n", " \"_mean_sale_to_list_\": \"Mean Sale to List Ratio\",\n", " \"_median_sale_price_\": \"Median Sale Price\",\n", " \"_pct_sold_above_list_\": \"% Sold Above List\",\n", " \"_pct_sold_below_list_\": \"% Sold Below List\",\n", " \"_sales_count_now_\": \"Nowcast\",\n", "}\n", "\n", "data_dir_path = get_data_path_for_config(CONFIG_NAME)\n", "\n", "for filename in os.listdir(data_dir_path):\n", " if filename.endswith(\".csv\"):\n", " print(\"processing \" + filename)\n", " # ignore monthly data for now since it is redundant\n", " if \"month\" in filename:\n", " continue\n", "\n", " cur_df = pd.read_csv(os.path.join(data_dir_path, filename))\n", "\n", " cur_df = set_home_type(cur_df, filename)\n", "\n", " data_frames = handle_slug_column_mappings(\n", " data_frames, slug_column_mappings, exclude_columns, filename, cur_df\n", " )\n", "\n", "\n", "combined_df = get_combined_df(\n", " data_frames,\n", " [\n", " \"RegionID\",\n", " \"SizeRank\",\n", " \"RegionName\",\n", " \"RegionType\",\n", " \"StateName\",\n", " \"Home Type\",\n", " \"Date\",\n", " ],\n", ")\n", "\n", "combined_df" ] }, { "cell_type": "code", "execution_count": 4, "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 StatescountryNaNSFR2008-02-02NaN172000.0NaNNaNNaNNaNNaNNaNNaNNaNNaN
11020010United StatescountryNaNSFR2008-02-09NaN165400.0NaNNaNNaNNaNNaNNaNNaNNaNNaN
21020010United StatescountryNaNSFR2008-02-16NaN168000.0NaNNaNNaNNaNNaNNaNNaNNaNNaN
31020010United StatescountryNaNSFR2008-02-23NaN167600.0NaN167600.0NaNNaNNaNNaNNaNNaNNaN
41020010United StatescountryNaNSFR2008-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 NaN \n", "1 102001 0 United States country NaN \n", "2 102001 0 United States country NaN \n", "3 102001 0 United States country NaN \n", "4 102001 0 United States country NaN \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": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Adjust column names\n", "final_df = combined_df.rename(\n", " columns={\n", " \"RegionID\": \"Region ID\",\n", " \"SizeRank\": \"Size Rank\",\n", " \"RegionName\": \"Region\",\n", " \"RegionType\": \"Region Type\",\n", " \"StateName\": \"State\",\n", " }\n", ")\n", "\n", "final_df[\"Date\"] = pd.to_datetime(final_df[\"Date\"])\n", "final_df.sort_values(by=[\"Region ID\", \"Home Type\", \"Date\"])" ] }, { "cell_type": "code", "execution_count": 5, "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 StatescountryNaNSFR2008-02-02NaN172000.0NaNNaNNaNNaNNaNNaNNaNNaNNaN
11020010United StatescountryNaNSFR2008-02-09NaN165400.0NaNNaNNaNNaNNaNNaNNaNNaNNaN
21020010United StatescountryNaNSFR2008-02-16NaN168000.0NaNNaNNaNNaNNaNNaNNaNNaNNaN
31020010United StatescountryNaNSFR2008-02-23NaN167600.0NaN167600.0NaNNaNNaNNaNNaNNaNNaN
41020010United StatescountryNaNSFR2008-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 NaN \n", "1 102001 0 United States country NaN \n", "2 102001 0 United States country NaN \n", "3 102001 0 United States country NaN \n", "4 102001 0 United States country NaN \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": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "final_df[\"Date\"] = pd.to_datetime(final_df[\"Date\"], format=\"%Y-%m-%d\")\n", "\n", "final_df" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "save_final_df_as_jsonl(CONFIG_NAME, final_df)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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 }