Skip to content

Commit

Permalink
WIP: import council data script
Browse files Browse the repository at this point in the history
  • Loading branch information
struan committed Mar 11, 2024
1 parent d2902f0 commit ded817e
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions hub/management/commands/import_council_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from django.conf import settings

import pandas as pd
from mysoc_dataset import get_dataset_url

from hub.models import AreaData, DataSet

from .base_importers import BaseImportFromDataFrameCommand


class Command(BaseImportFromDataFrameCommand):
cons_row = "gss-code"
message = "Importing council population data"
uses_gss = True
do_not_convert = True

area_type = "STC"

defaults = {
"data_type": "integer",
"category": "place",
"subcategory": "",
"release_date": "February 2023",
"label": "Council population",
"source_label": "Data from mySociety.",
"source": "https://www.mysociety.org/",
"source_type": "csv",
"table": "areadata",
"default_value": 1000,
"data_url": "",
"comparators": DataSet.numerical_comparators(),
"unit_type": "raw",
"unit_distribution": "people_in_area",
}

data_sets = {
"council_population_count": {
"defaults": defaults,
"col": "pop-2020",
},
}

def get_dataframe(self):
url = get_dataset_url(
repo_name="uk_local_authority_names_and_codes",
package_name="uk_la_future",
version_name="1",
file_name="uk_local_authorities_future.csv",
done_survey=True,
)
df = pd.read_csv(url)

print(df.columns)
return df

0 comments on commit ded817e

Please sign in to comment.