diff --git a/hub/management/commands/import_council_data.py b/hub/management/commands/import_council_data.py new file mode 100644 index 000000000..0d8f08b06 --- /dev/null +++ b/hub/management/commands/import_council_data.py @@ -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