{ "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 = \"home_values\"" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "processing City_zhvi_uc_condo_tier_0.33_0.67_sm_sa_month.csv\n", "processing City_zhvi_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Metro_zhvi_uc_sfrcondo_tier_0.67_1.0_sm_sa_month.csv\n", "processing County_zhvi_uc_sfrcondo_tier_0.67_1.0_sm_sa_month.csv\n", "processing Metro_zhvi_bdrmcnt_2_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing County_zhvi_bdrmcnt_4_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing County_zhvi_uc_sfr_tier_0.33_0.67_sm_sa_month.csv\n", "processing Neighborhood_zhvi_bdrmcnt_4_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing State_zhvi_uc_sfr_tier_0.33_0.67_sm_sa_month.csv\n", "processing County_zhvi_uc_condo_tier_0.33_0.67_sm_sa_month.csv\n", "processing City_zhvi_bdrmcnt_4_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing State_zhvi_bdrmcnt_5_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Zip_zhvi_bdrmcnt_2_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing City_zhvi_uc_sfrcondo_tier_0.67_1.0_sm_sa_month.csv\n", "processing Zip_zhvi_uc_condo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Neighborhood_zhvi_uc_sfr_sm_sa_month.csv\n", "processing Metro_zhvi_uc_sfr_tier_0.33_0.67_sm_sa_month.csv\n", "processing State_zhvi_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Zip_zhvi_bdrmcnt_1_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing County_zhvi_bdrmcnt_5_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Metro_zhvi_uc_condo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Metro_zhvi_bdrmcnt_3_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Neighborhood_zhvi_bdrmcnt_5_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Zip_zhvi_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing State_zhvi_uc_sfrcondo_tier_0.0_0.33_sm_sa_month.csv\n", "processing Metro_zhvi_bdrmcnt_1_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Zip_zhvi_uc_sfr_tier_0.33_0.67_sm_sa_month.csv\n", "processing City_zhvi_bdrmcnt_5_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing State_zhvi_bdrmcnt_4_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing State_zhvi_uc_condo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Zip_zhvi_bdrmcnt_3_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Neighborhood_zhvi_bdrmcnt_1_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing City_zhvi_bdrmcnt_3_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing County_zhvi_bdrmcnt_1_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Neighborhood_zhvi_uc_condo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Metro_zhvi_uc_sfrcondo_tier_0.33_0.67_month.csv\n", "processing Zip_zhvi_bdrmcnt_5_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing County_zhvi_uc_sfrcondo_tier_0.0_0.33_sm_sa_month.csv\n", "processing State_zhvi_bdrmcnt_2_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Metro_zhvi_uc_sfrcondo_tier_0.0_0.33_sm_sa_month.csv\n", "processing City_zhvi_uc_sfr_tier_0.33_0.67_sm_sa_month.csv\n", "processing City_zhvi_bdrmcnt_1_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Neighborhood_zhvi_bdrmcnt_3_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Metro_zhvi_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Metro_zhvi_bdrmcnt_5_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing County_zhvi_bdrmcnt_3_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing City_zhvi_bdrmcnt_2_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Neighborhood_zhvi_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing State_zhvi_uc_sfrcondo_tier_0.67_1.0_sm_sa_month.csv\n", "processing Zip_zhvi_bdrmcnt_4_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing State_zhvi_bdrmcnt_3_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing State_zhvi_bdrmcnt_1_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Neighborhood_zhvi_bdrmcnt_2_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing County_zhvi_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing County_zhvi_bdrmcnt_2_uc_sfrcondo_tier_0.33_0.67_sm_sa_month.csv\n", "processing Metro_zhvi_bdrmcnt_4_uc_sfrcondo_tier_0.33_0.67_sm_sa_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", "
RegionIDSizeRankRegionNameRegionTypeStateNameBedroom CountHome TypeDateMid Tier ZHVI (Smoothed) (Seasonally Adjusted)Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted)Top Tier ZHVI (Smoothed) (Seasonally Adjusted)
0348Alaskastatenan1-Bedroomall homes2000-01-3181310.639504NaNNaN
1348Alaskastatenan1-Bedroomall homes2000-02-2980419.761984NaNNaN
2348Alaskastatenan1-Bedroomall homes2000-03-3180480.449461NaNNaN
3348Alaskastatenan1-Bedroomall homes2000-04-3079799.206525NaNNaN
4348Alaskastatenan1-Bedroomall homes2000-05-3179666.469861NaNNaN
....................................
1179076251WyomingstatenanAll Bedroomscondo/co-op2023-09-30486974.735908NaNNaN
1179086251WyomingstatenanAll Bedroomscondo/co-op2023-10-31485847.539614NaNNaN
1179096251WyomingstatenanAll Bedroomscondo/co-op2023-11-30484223.885775NaNNaN
1179106251WyomingstatenanAll Bedroomscondo/co-op2023-12-31481522.403338NaNNaN
1179116251WyomingstatenanAll Bedroomscondo/co-op2024-01-31481181.718200NaNNaN
\n", "

117912 rows × 11 columns

\n", "
" ], "text/plain": [ " RegionID SizeRank RegionName RegionType StateName Bedroom Count \\\n", "0 3 48 Alaska state nan 1-Bedroom \n", "1 3 48 Alaska state nan 1-Bedroom \n", "2 3 48 Alaska state nan 1-Bedroom \n", "3 3 48 Alaska state nan 1-Bedroom \n", "4 3 48 Alaska state nan 1-Bedroom \n", "... ... ... ... ... ... ... \n", "117907 62 51 Wyoming state nan All Bedrooms \n", "117908 62 51 Wyoming state nan All Bedrooms \n", "117909 62 51 Wyoming state nan All Bedrooms \n", "117910 62 51 Wyoming state nan All Bedrooms \n", "117911 62 51 Wyoming state nan All Bedrooms \n", "\n", " Home Type Date \\\n", "0 all homes 2000-01-31 \n", "1 all homes 2000-02-29 \n", "2 all homes 2000-03-31 \n", "3 all homes 2000-04-30 \n", "4 all homes 2000-05-31 \n", "... ... ... \n", "117907 condo/co-op 2023-09-30 \n", "117908 condo/co-op 2023-10-31 \n", "117909 condo/co-op 2023-11-30 \n", "117910 condo/co-op 2023-12-31 \n", "117911 condo/co-op 2024-01-31 \n", "\n", " Mid Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n", "0 81310.639504 \n", "1 80419.761984 \n", "2 80480.449461 \n", "3 79799.206525 \n", "4 79666.469861 \n", "... ... \n", "117907 486974.735908 \n", "117908 485847.539614 \n", "117909 484223.885775 \n", "117910 481522.403338 \n", "117911 481181.718200 \n", "\n", " Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n", "0 NaN \n", "1 NaN \n", "2 NaN \n", "3 NaN \n", "4 NaN \n", "... ... \n", "117907 NaN \n", "117908 NaN \n", "117909 NaN \n", "117910 NaN \n", "117911 NaN \n", "\n", " Top Tier ZHVI (Smoothed) (Seasonally Adjusted) \n", "0 NaN \n", "1 NaN \n", "2 NaN \n", "3 NaN \n", "4 NaN \n", "... ... \n", "117907 NaN \n", "117908 NaN \n", "117909 NaN \n", "117910 NaN \n", "117911 NaN \n", "\n", "[117912 rows x 11 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_frames = []\n", "\n", "slug_column_mappings = {\n", " \"_tier_0.0_0.33_\": \"Bottom Tier ZHVI\",\n", " \"_tier_0.33_0.67_\": \"Mid Tier ZHVI\",\n", " \"_tier_0.67_1.0_\": \"Top Tier ZHVI\",\n", " \"\": \"ZHVI\",\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", " cur_df = pd.read_csv(os.path.join(data_dir_path, filename))\n", " exclude_columns = [\n", " \"RegionID\",\n", " \"SizeRank\",\n", " \"RegionName\",\n", " \"RegionType\",\n", " \"StateName\",\n", " \"Bedroom Count\",\n", " \"Home Type\",\n", " ]\n", "\n", " if \"Zip\" in filename:\n", " continue\n", " if \"Neighborhood\" in filename:\n", " continue\n", " if \"City\" in filename:\n", " continue\n", " if \"Metro\" in filename:\n", " continue\n", " if \"County\" in filename:\n", " continue\n", "\n", " if \"City\" in filename:\n", " exclude_columns = exclude_columns + [\"State\", \"Metro\", \"CountyName\"]\n", " elif \"Zip\" in filename:\n", " exclude_columns = exclude_columns + [\n", " \"State\",\n", " \"City\",\n", " \"Metro\",\n", " \"CountyName\",\n", " ]\n", " elif \"County\" in filename:\n", " exclude_columns = exclude_columns + [\n", " \"State\",\n", " \"Metro\",\n", " \"StateCodeFIPS\",\n", " \"MunicipalCodeFIPS\",\n", " ]\n", " elif \"Neighborhood\" in filename:\n", " exclude_columns = exclude_columns + [\n", " \"State\",\n", " \"City\",\n", " \"Metro\",\n", " \"CountyName\",\n", " ]\n", "\n", " if \"_bdrmcnt_1_\" in filename:\n", " cur_df[\"Bedroom Count\"] = \"1-Bedroom\"\n", " elif \"_bdrmcnt_2_\" in filename:\n", " cur_df[\"Bedroom Count\"] = \"2-Bedrooms\"\n", " elif \"_bdrmcnt_3_\" in filename:\n", " cur_df[\"Bedroom Count\"] = \"3-Bedrooms\"\n", " elif \"_bdrmcnt_4_\" in filename:\n", " cur_df[\"Bedroom Count\"] = \"4-Bedrooms\"\n", " elif \"_bdrmcnt_5_\" in filename:\n", " cur_df[\"Bedroom Count\"] = \"5+-Bedrooms\"\n", " else:\n", " cur_df[\"Bedroom Count\"] = \"All Bedrooms\"\n", "\n", " cur_df = set_home_type(cur_df, filename)\n", "\n", " cur_df[\"StateName\"] = cur_df[\"StateName\"].astype(str)\n", " cur_df[\"RegionName\"] = cur_df[\"RegionName\"].astype(str)\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", " \"Bedroom Count\",\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", "
RegionIDSizeRankRegionNameRegionTypeStateNameBedroom CountHome TypeDateMid Tier ZHVI (Smoothed) (Seasonally Adjusted)Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted)Top Tier ZHVI (Smoothed) (Seasonally Adjusted)
0348AlaskastateAlaska1-Bedroomall homes2000-01-3181310.639504NaNNaN
1348AlaskastateAlaska1-Bedroomall homes2000-02-2980419.761984NaNNaN
2348AlaskastateAlaska1-Bedroomall homes2000-03-3180480.449461NaNNaN
3348AlaskastateAlaska1-Bedroomall homes2000-04-3079799.206525NaNNaN
4348AlaskastateAlaska1-Bedroomall homes2000-05-3179666.469861NaNNaN
....................................
1179076251WyomingstateWyomingAll Bedroomscondo/co-op2023-09-30486974.735908NaNNaN
1179086251WyomingstateWyomingAll Bedroomscondo/co-op2023-10-31485847.539614NaNNaN
1179096251WyomingstateWyomingAll Bedroomscondo/co-op2023-11-30484223.885775NaNNaN
1179106251WyomingstateWyomingAll Bedroomscondo/co-op2023-12-31481522.403338NaNNaN
1179116251WyomingstateWyomingAll Bedroomscondo/co-op2024-01-31481181.718200NaNNaN
\n", "

117912 rows × 11 columns

\n", "
" ], "text/plain": [ " RegionID SizeRank RegionName RegionType StateName Bedroom Count \\\n", "0 3 48 Alaska state Alaska 1-Bedroom \n", "1 3 48 Alaska state Alaska 1-Bedroom \n", "2 3 48 Alaska state Alaska 1-Bedroom \n", "3 3 48 Alaska state Alaska 1-Bedroom \n", "4 3 48 Alaska state Alaska 1-Bedroom \n", "... ... ... ... ... ... ... \n", "117907 62 51 Wyoming state Wyoming All Bedrooms \n", "117908 62 51 Wyoming state Wyoming All Bedrooms \n", "117909 62 51 Wyoming state Wyoming All Bedrooms \n", "117910 62 51 Wyoming state Wyoming All Bedrooms \n", "117911 62 51 Wyoming state Wyoming All Bedrooms \n", "\n", " Home Type Date \\\n", "0 all homes 2000-01-31 \n", "1 all homes 2000-02-29 \n", "2 all homes 2000-03-31 \n", "3 all homes 2000-04-30 \n", "4 all homes 2000-05-31 \n", "... ... ... \n", "117907 condo/co-op 2023-09-30 \n", "117908 condo/co-op 2023-10-31 \n", "117909 condo/co-op 2023-11-30 \n", "117910 condo/co-op 2023-12-31 \n", "117911 condo/co-op 2024-01-31 \n", "\n", " Mid Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n", "0 81310.639504 \n", "1 80419.761984 \n", "2 80480.449461 \n", "3 79799.206525 \n", "4 79666.469861 \n", "... ... \n", "117907 486974.735908 \n", "117908 485847.539614 \n", "117909 484223.885775 \n", "117910 481522.403338 \n", "117911 481181.718200 \n", "\n", " Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n", "0 NaN \n", "1 NaN \n", "2 NaN \n", "3 NaN \n", "4 NaN \n", "... ... \n", "117907 NaN \n", "117908 NaN \n", "117909 NaN \n", "117910 NaN \n", "117911 NaN \n", "\n", " Top Tier ZHVI (Smoothed) (Seasonally Adjusted) \n", "0 NaN \n", "1 NaN \n", "2 NaN \n", "3 NaN \n", "4 NaN \n", "... ... \n", "117907 NaN \n", "117908 NaN \n", "117909 NaN \n", "117910 NaN \n", "117911 NaN \n", "\n", "[117912 rows x 11 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "final_df = combined_df\n", "\n", "for index, row in final_df.iterrows():\n", " if row[\"RegionType\"] == \"city\":\n", " final_df.at[index, \"City\"] = row[\"RegionName\"]\n", " elif row[\"RegionType\"] == \"county\":\n", " final_df.at[index, \"County\"] = row[\"RegionName\"]\n", " if row[\"RegionType\"] == \"state\":\n", " final_df.at[index, \"StateName\"] = row[\"RegionName\"]\n", "\n", "# coalesce State and StateName columns\n", "# final_df[\"State\"] = final_df[\"State\"].combine_first(final_df[\"StateName\"])\n", "# final_df[\"County\"] = final_df[\"County\"].combine_first(final_df[\"CountyName\"])\n", "\n", "# final_df = final_df.drop(\n", "# columns=[\n", "# \"StateName\",\n", "# # \"CountyName\"\n", "# ]\n", "# )\n", "final_df" ] }, { "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", "
Region IDSize RankRegionRegion TypeStateBedroom CountHome TypeDateMid Tier ZHVI (Smoothed) (Seasonally Adjusted)Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted)Top Tier ZHVI (Smoothed) (Seasonally Adjusted)
0348AlaskastateAlaska1-Bedroomall homes2000-01-3181310.639504NaNNaN
1348AlaskastateAlaska1-Bedroomall homes2000-02-2980419.761984NaNNaN
2348AlaskastateAlaska1-Bedroomall homes2000-03-3180480.449461NaNNaN
3348AlaskastateAlaska1-Bedroomall homes2000-04-3079799.206525NaNNaN
4348AlaskastateAlaska1-Bedroomall homes2000-05-3179666.469861NaNNaN
....................................
1179076251WyomingstateWyomingAll Bedroomscondo/co-op2023-09-30486974.735908NaNNaN
1179086251WyomingstateWyomingAll Bedroomscondo/co-op2023-10-31485847.539614NaNNaN
1179096251WyomingstateWyomingAll Bedroomscondo/co-op2023-11-30484223.885775NaNNaN
1179106251WyomingstateWyomingAll Bedroomscondo/co-op2023-12-31481522.403338NaNNaN
1179116251WyomingstateWyomingAll Bedroomscondo/co-op2024-01-31481181.718200NaNNaN
\n", "

117912 rows × 11 columns

\n", "
" ], "text/plain": [ " Region ID Size Rank Region Region Type State Bedroom Count \\\n", "0 3 48 Alaska state Alaska 1-Bedroom \n", "1 3 48 Alaska state Alaska 1-Bedroom \n", "2 3 48 Alaska state Alaska 1-Bedroom \n", "3 3 48 Alaska state Alaska 1-Bedroom \n", "4 3 48 Alaska state Alaska 1-Bedroom \n", "... ... ... ... ... ... ... \n", "117907 62 51 Wyoming state Wyoming All Bedrooms \n", "117908 62 51 Wyoming state Wyoming All Bedrooms \n", "117909 62 51 Wyoming state Wyoming All Bedrooms \n", "117910 62 51 Wyoming state Wyoming All Bedrooms \n", "117911 62 51 Wyoming state Wyoming All Bedrooms \n", "\n", " Home Type Date \\\n", "0 all homes 2000-01-31 \n", "1 all homes 2000-02-29 \n", "2 all homes 2000-03-31 \n", "3 all homes 2000-04-30 \n", "4 all homes 2000-05-31 \n", "... ... ... \n", "117907 condo/co-op 2023-09-30 \n", "117908 condo/co-op 2023-10-31 \n", "117909 condo/co-op 2023-11-30 \n", "117910 condo/co-op 2023-12-31 \n", "117911 condo/co-op 2024-01-31 \n", "\n", " Mid Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n", "0 81310.639504 \n", "1 80419.761984 \n", "2 80480.449461 \n", "3 79799.206525 \n", "4 79666.469861 \n", "... ... \n", "117907 486974.735908 \n", "117908 485847.539614 \n", "117909 484223.885775 \n", "117910 481522.403338 \n", "117911 481181.718200 \n", "\n", " Bottom Tier ZHVI (Smoothed) (Seasonally Adjusted) \\\n", "0 NaN \n", "1 NaN \n", "2 NaN \n", "3 NaN \n", "4 NaN \n", "... ... \n", "117907 NaN \n", "117908 NaN \n", "117909 NaN \n", "117910 NaN \n", "117911 NaN \n", "\n", " Top Tier ZHVI (Smoothed) (Seasonally Adjusted) \n", "0 NaN \n", "1 NaN \n", "2 NaN \n", "3 NaN \n", "4 NaN \n", "... ... \n", "117907 NaN \n", "117908 NaN \n", "117909 NaN \n", "117910 NaN \n", "117911 NaN \n", "\n", "[117912 rows x 11 columns]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "final_df = final_df.rename(\n", " columns={\n", " \"RegionID\": \"Region ID\",\n", " \"SizeRank\": \"Size Rank\",\n", " \"RegionName\": \"Region\",\n", " \"RegionType\": \"Region Type\",\n", " \"StateCodeFIPS\": \"State Code FIPS\",\n", " \"StateName\": \"State\",\n", " \"MunicipalCodeFIPS\": \"Municipal Code FIPS\",\n", " }\n", ")\n", "\n", "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 }