Skip to content

Commit

Permalink
fix black in notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
ajparsons committed Mar 7, 2023
1 parent f8e8168 commit 79228d7
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions notebooks/generate_2023_pop.ipynb
Expand Up @@ -14,7 +14,7 @@
"\n",
"df = pd.read_csv(\n",
" Path(\"..\", \"data\", \"packages\", \"uk_la_future\", \"uk_local_authorities_future.csv\")\n",
")\n"
")"
]
},
{
Expand Down Expand Up @@ -79,7 +79,7 @@
" index=\"local-authority-type-name\",\n",
" values=\"local-authority-code\",\n",
" aggfunc=\"count\",\n",
")\n"
")"
]
},
{
Expand Down Expand Up @@ -181,15 +181,21 @@
}
],
"source": [
"\n",
"# in a pivot table where replaced-by is the index\n",
"# I want the sum of area, and pop-2000\n",
"# I want the average of x and y\n",
"\n",
"pt = d.pivot_table(\n",
" index=\"replaced-by\",\n",
" values=[\"area\", \"pop-2020\", \"x\", \"y\", \"long\", \"lat\"],\n",
" aggfunc={\"area\": \"sum\", \"pop-2020\": \"sum\", \"x\": \"mean\", \"y\": \"mean\", \"long\": \"mean\", \"lat\": \"mean\"},\n",
" aggfunc={\n",
" \"area\": \"sum\",\n",
" \"pop-2020\": \"sum\",\n",
" \"x\": \"mean\",\n",
" \"y\": \"mean\",\n",
" \"long\": \"mean\",\n",
" \"lat\": \"mean\",\n",
" },\n",
")\n",
"pt[\"area\"] = pt[\"area\"].astype(int)\n",
"pt[\"pop-2020\"] = pt[\"pop-2020\"].astype(int)\n",
Expand All @@ -215,13 +221,10 @@
}
],
"source": [
"\n",
"just_area_pop = pt[[\"area\", \"pop-2020\"]]\n",
"\n",
"# print as comma seperates values in the notebook without saving a file\n",
"print(just_area_pop.to_csv(None, index=True))\n",
"\n",
"\n"
"print(just_area_pop.to_csv(None, index=True))"
]
},
{
Expand Down

0 comments on commit 79228d7

Please sign in to comment.