Skip to content

Commit

Permalink
Refactor code to remove unnecessary execution
Browse files Browse the repository at this point in the history
counts
  • Loading branch information
asiripanich committed Oct 23, 2024
1 parent 1e8fd09 commit d7a288a
Showing 1 changed file with 7 additions and 109 deletions.
116 changes: 7 additions & 109 deletions tidy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -19,73 +19,9 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Divisions': shape: (19, 2)\n",
" ┌───────────────┬─────────────────────────────────┐\n",
" │ division_code ┆ division_title │\n",
" │ --- ┆ --- │\n",
" │ str ┆ str │\n",
" ╞═══════════════╪═════════════════════════════════╡\n",
" │ A ┆ Agriculture, Forestry and Fish… │\n",
" │ B ┆ Mining │\n",
" │ C ┆ Manufacturing │\n",
" │ D ┆ Electricity, Gas, Water and Wa… │\n",
" │ E ┆ Construction │\n",
" │ … ┆ … │\n",
" │ O ┆ Public Administration and Safe… │\n",
" │ P ┆ Education and Training │\n",
" │ Q ┆ Health Care and Social Assista… │\n",
" │ R ┆ Arts and Recreation Services │\n",
" │ S ┆ Other Services │\n",
" └───────────────┴─────────────────────────────────┘,\n",
" 'Groups': shape: (214, 3)\n",
" ┌────────────┬─────────────────────────────────┬──────────────┐\n",
" │ group_code ┆ group_title ┆ group_parent │\n",
" │ --- ┆ --- ┆ --- │\n",
" │ str ┆ str ┆ str │\n",
" ╞════════════╪═════════════════════════════════╪══════════════╡\n",
" │ 011 ┆ Nursery and Floriculture Produ… ┆ 01 │\n",
" │ 012 ┆ Mushroom and Vegetable Growing ┆ 01 │\n",
" │ 013 ┆ Fruit and Tree Nut Growing ┆ 01 │\n",
" │ 014 ┆ Sheep, Beef Cattle and Grain F… ┆ 01 │\n",
" │ 015 ┆ Other Crop Growing ┆ 01 │\n",
" │ … ┆ … ┆ … │\n",
" │ 952 ┆ Funeral, Crematorium and Cemet… ┆ 95 │\n",
" │ 953 ┆ Other Personal Services ┆ 95 │\n",
" │ 954 ┆ Religious Services ┆ 95 │\n",
" │ 955 ┆ Civic, Professional and Other … ┆ 95 │\n",
" │ 960 ┆ Private Households Employing S… ┆ 96 │\n",
" └────────────┴─────────────────────────────────┴──────────────┘,\n",
" 'Classes': shape: (506, 3)\n",
" ┌────────────┬─────────────────────────────────┬──────────────┐\n",
" │ class_code ┆ class_title ┆ class_parent │\n",
" │ --- ┆ --- ┆ --- │\n",
" │ str ┆ str ┆ str │\n",
" ╞════════════╪═════════════════════════════════╪══════════════╡\n",
" │ 0111 ┆ Nursery Production (Under Cove… ┆ 011 │\n",
" │ 0112 ┆ Nursery Production (Outdoors) ┆ 011 │\n",
" │ 0113 ┆ Turf Growing ┆ 011 │\n",
" │ 0114 ┆ Floriculture Production (Under… ┆ 011 │\n",
" │ 0115 ┆ Floriculture Production (Outdo… ┆ 011 │\n",
" │ … ┆ … ┆ … │\n",
" │ 9552 ┆ Labour Association Services ┆ 955 │\n",
" │ 9559 ┆ Other Interest Group Services … ┆ 955 │\n",
" │ 9601 ┆ Private Households Employing S… ┆ 960 │\n",
" │ 9602 ┆ Undifferentiated Goods-Produci… ┆ 960 │\n",
" │ 9603 ┆ Undifferentiated Service-Produ… ┆ 960 │\n",
" └────────────┴─────────────────────────────────┴──────────────┘}"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"def read_anzsic_sheet(sheet_name, prefix):\n",
" df = (\n",
Expand Down Expand Up @@ -122,47 +58,9 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><style>\n",
".dataframe > thead > tr,\n",
".dataframe > tbody > tr {\n",
" text-align: right;\n",
" white-space: pre-wrap;\n",
"}\n",
"</style>\n",
"<small>shape: (86, 3)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>division_code</th><th>subdivision_code</th><th>subdivision_title</th></tr><tr><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;A&quot;</td><td>&quot;01&quot;</td><td>&quot;Agriculture&quot;</td></tr><tr><td>&quot;A&quot;</td><td>&quot;02&quot;</td><td>&quot;Aquaculture&quot;</td></tr><tr><td>&quot;A&quot;</td><td>&quot;03&quot;</td><td>&quot;Forestry and Logging&quot;</td></tr><tr><td>&quot;A&quot;</td><td>&quot;04&quot;</td><td>&quot;Fishing, Hunting and Trapping&quot;</td></tr><tr><td>&quot;A&quot;</td><td>&quot;05&quot;</td><td>&quot;Agriculture, Forestry and Fish…</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;R&quot;</td><td>&quot;91&quot;</td><td>&quot;Sports and Recreation Activiti…</td></tr><tr><td>&quot;R&quot;</td><td>&quot;92&quot;</td><td>&quot;Gambling Activities&quot;</td></tr><tr><td>&quot;S&quot;</td><td>&quot;94&quot;</td><td>&quot;Repair and Maintenance&quot;</td></tr><tr><td>&quot;S&quot;</td><td>&quot;95&quot;</td><td>&quot;Personal and Other Services&quot;</td></tr><tr><td>&quot;S&quot;</td><td>&quot;96&quot;</td><td>&quot;Private Households Employing S…</td></tr></tbody></table></div>"
],
"text/plain": [
"shape: (86, 3)\n",
"┌───────────────┬──────────────────┬─────────────────────────────────┐\n",
"│ division_code ┆ subdivision_code ┆ subdivision_title │\n",
"│ --- ┆ --- ┆ --- │\n",
"│ str ┆ str ┆ str │\n",
"╞═══════════════╪══════════════════╪═════════════════════════════════╡\n",
"│ A ┆ 01 ┆ Agriculture │\n",
"│ A ┆ 02 ┆ Aquaculture │\n",
"│ A ┆ 03 ┆ Forestry and Logging │\n",
"│ A ┆ 04 ┆ Fishing, Hunting and Trapping │\n",
"│ A ┆ 05 ┆ Agriculture, Forestry and Fish… │\n",
"│ … ┆ … ┆ … │\n",
"│ R ┆ 91 ┆ Sports and Recreation Activiti… │\n",
"│ R ┆ 92 ┆ Gambling Activities │\n",
"│ S ┆ 94 ┆ Repair and Maintenance │\n",
"│ S ┆ 95 ┆ Personal and Other Services │\n",
"│ S ┆ 96 ┆ Private Households Employing S… │\n",
"└───────────────┴──────────────────┴─────────────────────────────────┘"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"# Create Subdivisions\n",
"anzsic06[\"Subdivisions\"] = pl.read_excel(\n",
Expand Down Expand Up @@ -194,7 +92,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -216,7 +114,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
Expand Down

0 comments on commit d7a288a

Please sign in to comment.