{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import os\n", "\n", "from helpers import (\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": 3, "metadata": {}, "outputs": [], "source": [ "DATA_DIR = \"../data\"\n", "PROCESSED_DIR = \"../processed/\"\n", "FACET_DIR = \"rentals/\"\n", "FULL_DATA_DIR_PATH = os.path.join(DATA_DIR, FACET_DIR)\n", "FULL_PROCESSED_DIR_PATH = os.path.join(PROCESSED_DIR, FACET_DIR)" ] }, { "cell_type": "code", "execution_count": 7, "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", "
RegionIDSizeRankRegionNameRegionTypeStateNameHome TypeStateMetroStateCodeFIPSMunicipalCodeFIPSDateRent (Smoothed)CountyNameRent (Smoothed) (Seasonally Adjusted)City
066146Ada CountycountyIDall homes plus multifamily16.0Boise City, ID16.01.02015-01-31927.493763NaN927.493763NaN
166146Ada CountycountyIDall homes plus multifamily16.0Boise City, ID16.01.02015-02-28931.690623NaN931.690623NaN
266146Ada CountycountyIDall homes plus multifamily16.0Boise City, ID16.01.02015-03-31932.568601NaN932.568601NaN
366146Ada CountycountyIDall homes plus multifamily16.0Boise City, ID16.01.02015-04-30933.148134NaN933.148134NaN
466146Ada CountycountyIDall homes plus multifamily16.0Boise City, ID16.01.02015-05-31941.045724NaN941.045724NaN
................................................
1258735857850713Cherry HillcityNJall homes plus multifamilyNJPhiladelphia-Camden-Wilmington, PA-NJ-DE-MDNaNNaN2023-08-312291.604800Camden County2244.961006NaN
1258736857850713Cherry HillcityNJall homes plus multifamilyNJPhiladelphia-Camden-Wilmington, PA-NJ-DE-MDNaNNaN2023-09-302296.188906Camden County2254.213172NaN
1258737857850713Cherry HillcityNJall homes plus multifamilyNJPhiladelphia-Camden-Wilmington, PA-NJ-DE-MDNaNNaN2023-10-312292.270938Camden County2261.540446NaN
1258738857850713Cherry HillcityNJall homes plus multifamilyNJPhiladelphia-Camden-Wilmington, PA-NJ-DE-MDNaNNaN2023-11-302253.417140Camden County2257.956024NaN
1258739857850713Cherry HillcityNJall homes plus multifamilyNJPhiladelphia-Camden-Wilmington, PA-NJ-DE-MDNaNNaN2023-12-312280.830303Camden County2280.830303NaN
\n", "

1258740 rows × 15 columns

\n", "
" ], "text/plain": [ " RegionID SizeRank RegionName RegionType StateName \\\n", "0 66 146 Ada County county ID \n", "1 66 146 Ada County county ID \n", "2 66 146 Ada County county ID \n", "3 66 146 Ada County county ID \n", "4 66 146 Ada County county ID \n", "... ... ... ... ... ... \n", "1258735 857850 713 Cherry Hill city NJ \n", "1258736 857850 713 Cherry Hill city NJ \n", "1258737 857850 713 Cherry Hill city NJ \n", "1258738 857850 713 Cherry Hill city NJ \n", "1258739 857850 713 Cherry Hill city NJ \n", "\n", " Home Type State \\\n", "0 all homes plus multifamily 16.0 \n", "1 all homes plus multifamily 16.0 \n", "2 all homes plus multifamily 16.0 \n", "3 all homes plus multifamily 16.0 \n", "4 all homes plus multifamily 16.0 \n", "... ... ... \n", "1258735 all homes plus multifamily NJ \n", "1258736 all homes plus multifamily NJ \n", "1258737 all homes plus multifamily NJ \n", "1258738 all homes plus multifamily NJ \n", "1258739 all homes plus multifamily NJ \n", "\n", " Metro StateCodeFIPS \\\n", "0 Boise City, ID 16.0 \n", "1 Boise City, ID 16.0 \n", "2 Boise City, ID 16.0 \n", "3 Boise City, ID 16.0 \n", "4 Boise City, ID 16.0 \n", "... ... ... \n", "1258735 Philadelphia-Camden-Wilmington, PA-NJ-DE-MD NaN \n", "1258736 Philadelphia-Camden-Wilmington, PA-NJ-DE-MD NaN \n", "1258737 Philadelphia-Camden-Wilmington, PA-NJ-DE-MD NaN \n", "1258738 Philadelphia-Camden-Wilmington, PA-NJ-DE-MD NaN \n", "1258739 Philadelphia-Camden-Wilmington, PA-NJ-DE-MD NaN \n", "\n", " MunicipalCodeFIPS Date Rent (Smoothed) CountyName \\\n", "0 1.0 2015-01-31 927.493763 NaN \n", "1 1.0 2015-02-28 931.690623 NaN \n", "2 1.0 2015-03-31 932.568601 NaN \n", "3 1.0 2015-04-30 933.148134 NaN \n", "4 1.0 2015-05-31 941.045724 NaN \n", "... ... ... ... ... \n", "1258735 NaN 2023-08-31 2291.604800 Camden County \n", "1258736 NaN 2023-09-30 2296.188906 Camden County \n", "1258737 NaN 2023-10-31 2292.270938 Camden County \n", "1258738 NaN 2023-11-30 2253.417140 Camden County \n", "1258739 NaN 2023-12-31 2280.830303 Camden County \n", "\n", " Rent (Smoothed) (Seasonally Adjusted) City \n", "0 927.493763 NaN \n", "1 931.690623 NaN \n", "2 932.568601 NaN \n", "3 933.148134 NaN \n", "4 941.045724 NaN \n", "... ... ... \n", "1258735 2244.961006 NaN \n", "1258736 2254.213172 NaN \n", "1258737 2261.540446 NaN \n", "1258738 2257.956024 NaN \n", "1258739 2280.830303 NaN \n", "\n", "[1258740 rows x 15 columns]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_frames = []\n", "\n", "slug_column_mappings = {\"\": \"Rent\"}\n", "\n", "for filename in os.listdir(FULL_DATA_DIR_PATH):\n", " if filename.endswith(\".csv\"):\n", " # print(\"processing \" + filename)\n", " cur_df = pd.read_csv(os.path.join(FULL_DATA_DIR_PATH, filename))\n", " exclude_columns = [\n", " \"RegionID\",\n", " \"SizeRank\",\n", " \"RegionName\",\n", " \"RegionType\",\n", " \"StateName\",\n", " \"Home Type\",\n", " ]\n", "\n", " cur_df[\"RegionName\"] = cur_df[\"RegionName\"].astype(str)\n", "\n", " cur_df = set_home_type(cur_df, filename)\n", "\n", " if \"City\" in filename:\n", " exclude_columns = [\n", " \"RegionID\",\n", " \"SizeRank\",\n", " \"RegionName\",\n", " \"RegionType\",\n", " \"StateName\",\n", " \"Home Type\",\n", " # City Specific\n", " \"State\",\n", " \"Metro\",\n", " \"CountyName\",\n", " ]\n", " elif \"Zip\" in filename:\n", " exclude_columns = [\n", " \"RegionID\",\n", " \"SizeRank\",\n", " \"RegionName\",\n", " \"RegionType\",\n", " \"StateName\",\n", " \"Home Type\",\n", " # Zip Specific\n", " \"State\",\n", " \"City\",\n", " \"Metro\",\n", " \"CountyName\",\n", " ]\n", " elif \"County\" in filename:\n", " exclude_columns = [\n", " \"RegionID\",\n", " \"SizeRank\",\n", " \"RegionName\",\n", " \"RegionType\",\n", " \"StateName\",\n", " \"Home Type\",\n", " # County Specific\n", " \"State\",\n", " \"Metro\",\n", " \"StateCodeFIPS\",\n", " \"MunicipalCodeFIPS\",\n", " ]\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": 8, "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", "
RegionIDSizeRankRegionNameRegionTypeHome TypeStateMetroStateCodeFIPSMunicipalCodeFIPSDateRent (Smoothed)Rent (Smoothed) (Seasonally Adjusted)CityCounty
066146Ada Countycountyall homes plus multifamilyAda CountyBoise City, ID16.01.02015-01-31927.493763927.493763NaNAda County
166146Ada Countycountyall homes plus multifamilyAda CountyBoise City, ID16.01.02015-02-28931.690623931.690623NaNAda County
266146Ada Countycountyall homes plus multifamilyAda CountyBoise City, ID16.01.02015-03-31932.568601932.568601NaNAda County
366146Ada Countycountyall homes plus multifamilyAda CountyBoise City, ID16.01.02015-04-30933.148134933.148134NaNAda County
466146Ada Countycountyall homes plus multifamilyAda CountyBoise City, ID16.01.02015-05-31941.045724941.045724NaNAda County
.............................................
1258735857850713Cherry Hillcityall homes plus multifamilyCamden CountyPhiladelphia-Camden-Wilmington, PA-NJ-DE-MDNaNNaN2023-08-312291.6048002244.961006Cherry HillNaN
1258736857850713Cherry Hillcityall homes plus multifamilyCamden CountyPhiladelphia-Camden-Wilmington, PA-NJ-DE-MDNaNNaN2023-09-302296.1889062254.213172Cherry HillNaN
1258737857850713Cherry Hillcityall homes plus multifamilyCamden CountyPhiladelphia-Camden-Wilmington, PA-NJ-DE-MDNaNNaN2023-10-312292.2709382261.540446Cherry HillNaN
1258738857850713Cherry Hillcityall homes plus multifamilyCamden CountyPhiladelphia-Camden-Wilmington, PA-NJ-DE-MDNaNNaN2023-11-302253.4171402257.956024Cherry HillNaN
1258739857850713Cherry Hillcityall homes plus multifamilyCamden CountyPhiladelphia-Camden-Wilmington, PA-NJ-DE-MDNaNNaN2023-12-312280.8303032280.830303Cherry HillNaN
\n", "

1258740 rows × 14 columns

\n", "
" ], "text/plain": [ " RegionID SizeRank RegionName RegionType \\\n", "0 66 146 Ada County county \n", "1 66 146 Ada County county \n", "2 66 146 Ada County county \n", "3 66 146 Ada County county \n", "4 66 146 Ada County county \n", "... ... ... ... ... \n", "1258735 857850 713 Cherry Hill city \n", "1258736 857850 713 Cherry Hill city \n", "1258737 857850 713 Cherry Hill city \n", "1258738 857850 713 Cherry Hill city \n", "1258739 857850 713 Cherry Hill city \n", "\n", " Home Type State \\\n", "0 all homes plus multifamily Ada County \n", "1 all homes plus multifamily Ada County \n", "2 all homes plus multifamily Ada County \n", "3 all homes plus multifamily Ada County \n", "4 all homes plus multifamily Ada County \n", "... ... ... \n", "1258735 all homes plus multifamily Camden County \n", "1258736 all homes plus multifamily Camden County \n", "1258737 all homes plus multifamily Camden County \n", "1258738 all homes plus multifamily Camden County \n", "1258739 all homes plus multifamily Camden County \n", "\n", " Metro StateCodeFIPS \\\n", "0 Boise City, ID 16.0 \n", "1 Boise City, ID 16.0 \n", "2 Boise City, ID 16.0 \n", "3 Boise City, ID 16.0 \n", "4 Boise City, ID 16.0 \n", "... ... ... \n", "1258735 Philadelphia-Camden-Wilmington, PA-NJ-DE-MD NaN \n", "1258736 Philadelphia-Camden-Wilmington, PA-NJ-DE-MD NaN \n", "1258737 Philadelphia-Camden-Wilmington, PA-NJ-DE-MD NaN \n", "1258738 Philadelphia-Camden-Wilmington, PA-NJ-DE-MD NaN \n", "1258739 Philadelphia-Camden-Wilmington, PA-NJ-DE-MD NaN \n", "\n", " MunicipalCodeFIPS Date Rent (Smoothed) \\\n", "0 1.0 2015-01-31 927.493763 \n", "1 1.0 2015-02-28 931.690623 \n", "2 1.0 2015-03-31 932.568601 \n", "3 1.0 2015-04-30 933.148134 \n", "4 1.0 2015-05-31 941.045724 \n", "... ... ... ... \n", "1258735 NaN 2023-08-31 2291.604800 \n", "1258736 NaN 2023-09-30 2296.188906 \n", "1258737 NaN 2023-10-31 2292.270938 \n", "1258738 NaN 2023-11-30 2253.417140 \n", "1258739 NaN 2023-12-31 2280.830303 \n", "\n", " Rent (Smoothed) (Seasonally Adjusted) City County \n", "0 927.493763 NaN Ada County \n", "1 931.690623 NaN Ada County \n", "2 932.568601 NaN Ada County \n", "3 933.148134 NaN Ada County \n", "4 941.045724 NaN Ada County \n", "... ... ... ... \n", "1258735 2244.961006 Cherry Hill NaN \n", "1258736 2254.213172 Cherry Hill NaN \n", "1258737 2261.540446 Cherry Hill NaN \n", "1258738 2257.956024 Cherry Hill NaN \n", "1258739 2280.830303 Cherry Hill NaN \n", "\n", "[1258740 rows x 14 columns]" ] }, "execution_count": 8, "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", "\n", "# coalesce State and StateName columns\n", "final_df[\"State\"] = final_df[\"State\"].combine_first(final_df[\"StateName\"])\n", "final_df[\"State\"] = final_df[\"County\"].combine_first(final_df[\"CountyName\"])\n", "\n", "final_df = final_df.drop(columns=[\"StateName\", \"CountyName\"])\n", "final_df" ] }, { "cell_type": "code", "execution_count": 6, "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", "
Region IDSize RankRegionRegion TypeHome TypeStateMetroState Code FIPSMunicipal Code FIPSDateRent (Smoothed)Rent (Smoothed) (Seasonally Adjusted)CityCounty
066146Ada Countycountyall homes plus multifamilyAda CountyBoise City, ID16.01.02015-01-31927.493763927.493763NaNAda County
166146Ada Countycountyall homes plus multifamilyAda CountyBoise City, ID16.01.02015-02-28931.690623931.690623NaNAda County
266146Ada Countycountyall homes plus multifamilyAda CountyBoise City, ID16.01.02015-03-31932.568601932.568601NaNAda County
366146Ada Countycountyall homes plus multifamilyAda CountyBoise City, ID16.01.02015-04-30933.148134933.148134NaNAda County
466146Ada Countycountyall homes plus multifamilyAda CountyBoise City, ID16.01.02015-05-31941.045724941.045724NaNAda County
.............................................
1258735857850713Cherry Hillcityall homes plus multifamilyCamden CountyNaNNaNNaN2023-08-312291.6048002244.961006Cherry HillNaN
1258736857850713Cherry Hillcityall homes plus multifamilyCamden CountyNaNNaNNaN2023-09-302296.1889062254.213172Cherry HillNaN
1258737857850713Cherry Hillcityall homes plus multifamilyCamden CountyNaNNaNNaN2023-10-312292.2709382261.540446Cherry HillNaN
1258738857850713Cherry Hillcityall homes plus multifamilyCamden CountyNaNNaNNaN2023-11-302253.4171402257.956024Cherry HillNaN
1258739857850713Cherry Hillcityall homes plus multifamilyCamden CountyNaNNaNNaN2023-12-312280.8303032280.830303Cherry HillNaN
\n", "

1258740 rows × 14 columns

\n", "
" ], "text/plain": [ " Region ID Size Rank Region Region Type \\\n", "0 66 146 Ada County county \n", "1 66 146 Ada County county \n", "2 66 146 Ada County county \n", "3 66 146 Ada County county \n", "4 66 146 Ada County county \n", "... ... ... ... ... \n", "1258735 857850 713 Cherry Hill city \n", "1258736 857850 713 Cherry Hill city \n", "1258737 857850 713 Cherry Hill city \n", "1258738 857850 713 Cherry Hill city \n", "1258739 857850 713 Cherry Hill city \n", "\n", " Home Type State Metro \\\n", "0 all homes plus multifamily Ada County Boise City, ID \n", "1 all homes plus multifamily Ada County Boise City, ID \n", "2 all homes plus multifamily Ada County Boise City, ID \n", "3 all homes plus multifamily Ada County Boise City, ID \n", "4 all homes plus multifamily Ada County Boise City, ID \n", "... ... ... ... \n", "1258735 all homes plus multifamily Camden County NaN \n", "1258736 all homes plus multifamily Camden County NaN \n", "1258737 all homes plus multifamily Camden County NaN \n", "1258738 all homes plus multifamily Camden County NaN \n", "1258739 all homes plus multifamily Camden County NaN \n", "\n", " State Code FIPS Municipal Code FIPS Date Rent (Smoothed) \\\n", "0 16.0 1.0 2015-01-31 927.493763 \n", "1 16.0 1.0 2015-02-28 931.690623 \n", "2 16.0 1.0 2015-03-31 932.568601 \n", "3 16.0 1.0 2015-04-30 933.148134 \n", "4 16.0 1.0 2015-05-31 941.045724 \n", "... ... ... ... ... \n", "1258735 NaN NaN 2023-08-31 2291.604800 \n", "1258736 NaN NaN 2023-09-30 2296.188906 \n", "1258737 NaN NaN 2023-10-31 2292.270938 \n", "1258738 NaN NaN 2023-11-30 2253.417140 \n", "1258739 NaN NaN 2023-12-31 2280.830303 \n", "\n", " Rent (Smoothed) (Seasonally Adjusted) City County \n", "0 927.493763 NaN Ada County \n", "1 931.690623 NaN Ada County \n", "2 932.568601 NaN Ada County \n", "3 933.148134 NaN Ada County \n", "4 941.045724 NaN Ada County \n", "... ... ... ... \n", "1258735 2244.961006 Cherry Hill NaN \n", "1258736 2254.213172 Cherry Hill NaN \n", "1258737 2261.540446 Cherry Hill NaN \n", "1258738 2257.956024 Cherry Hill NaN \n", "1258739 2280.830303 Cherry Hill NaN \n", "\n", "[1258740 rows x 14 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Adjust column names\n", "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", " \"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": 7, "metadata": {}, "outputs": [], "source": [ "save_final_df_as_jsonl(FULL_PROCESSED_DIR_PATH, 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 }