Skip to content

Commit

Permalink
Add HDB prices.
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotwutingfeng committed Aug 30, 2024
1 parent 6be6c26 commit 397b415
Show file tree
Hide file tree
Showing 3 changed files with 338 additions and 233 deletions.
86 changes: 85 additions & 1 deletion analysis/analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,90 @@
" print(stage, stage_mean_total_cost, stage_max_total_cost, stage_total_cost_std_dev)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"median_price_per_sq_ft_per_lease_year = pd.DataFrame.from_dict(\n",
" {\n",
" \"ANG MO KIO\": 9.79,\n",
" \"BEDOK\": 9.32,\n",
" \"BISHAN\": 11.27,\n",
" \"BUKIT BATOK\": 7.33,\n",
" \"BUKIT MERAH\": 10.8,\n",
" \"BUKIT PANJANG\": 7.08,\n",
" \"BUKIT TIMAH\": 12.86,\n",
" \"CENTRAL AREA\": 13.2, # Not a planning area.\n",
" \"CHOA CHU KANG\": 6.44,\n",
" \"CLEMENTI\": 9.95,\n",
" \"GEYLANG\": 10.53,\n",
" \"HOUGANG\": 8,\n",
" \"JURONG EAST\": 8.08,\n",
" \"JURONG WEST\": 6.8,\n",
" \"KALLANG\": 10.69,\n",
" \"MARINE PARADE\": 12.5,\n",
" \"PASIR RIS\": 7.63,\n",
" \"PUNGGOL\": 7.11,\n",
" \"QUEENSTOWN\": 11.22,\n",
" \"SEMBAWANG\": 6.54,\n",
" \"SENGKANG\": 6.97,\n",
" \"SERANGOON\": 9.74,\n",
" \"TAMPINES\": 8.34,\n",
" \"TOA PAYOH\": 10.77,\n",
" \"WOODLANDS\": 6.76,\n",
" \"YISHUN\": 7.69,\n",
" },\n",
" orient=\"index\",\n",
").reset_index()\n",
"median_price_per_sq_ft_per_lease_year.columns = [\n",
" \"planning_area\",\n",
" \"median_price_per_sq_ft_per_lease_year\",\n",
"]\n",
"\n",
"planning_area_agg_stats = (\n",
" station_agg_stats_by_stage[\"teck_lee\"]\n",
" .copy()\n",
" .groupby(by=[\"planning_area\", \"region\"])\n",
" .mean(numeric_only=True)\n",
" .reset_index()\n",
" .sort_values(by=[\"path_distance_mean\"])\n",
" .merge(median_price_per_sq_ft_per_lease_year, on=\"planning_area\", how=\"inner\")\n",
")\n",
"\n",
"hover_data={\n",
" \"haversine_distance_median\": True,\n",
" \"path_distance_median\": True,\n",
" \"region\": True,\n",
" \"planning_area\": True,\n",
"}\n",
"\n",
"fig = px.scatter_3d(\n",
" planning_area_agg_stats,\n",
" x=\"haversine_distance_median\",\n",
" y=\"path_distance_median\",\n",
" z=\"median_price_per_sq_ft_per_lease_year\",\n",
" color=\"region\",\n",
" range_x=[\n",
" planning_area_agg_stats[\"haversine_distance_median\"].max(),\n",
" planning_area_agg_stats[\"haversine_distance_median\"].min(),\n",
" ],\n",
" text=\"planning_area\",\n",
" hover_name=\"planning_area\",\n",
" hover_data=hover_data,\n",
" height=850,\n",
")\n",
"fig.update_layout(\n",
" scene=dict(\n",
" xaxis_title=\"Median Haversine (km)\",\n",
" yaxis_title=\"Median Path (km)\",\n",
" zaxis_title=\"$/sqft/yr\",\n",
" )\n",
")\n",
"fig.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -654,7 +738,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.4"
"version": "3.12.5"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 397b415

Please sign in to comment.