Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import command for bbowt member counts #611

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions hub/management/commands/import_berks_wt_member_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from django.conf import settings

import pandas as pd

from hub.models import DataSet

from .base_importers import BaseImportFromDataFrameCommand


class Command(BaseImportFromDataFrameCommand):
help = "Import Berkshire, Buckinghamshire and Oxfordshire Wildlife Trust member counts for post 2024 constituencies"

message = "importing Berkshire, Buckinghamshire and Oxfordshire wildlife trust member counts"
cons_row = "Constituency"
cons_col = "Constituency"
data_file = (
settings.BASE_DIR
/ "data"
/ "berks_bucks_oxon_wildlife_trust_member_counts.xlsx"
)
uses_gss = False

area_type = "WMC23"

data_sets = {
"bbox_wt_members": {
"defaults": {
"label": "Berkshire, Buckinghamshire and Oxfordshire Wildlife Trust members",
"data_type": "integer",
"category": "movement",
"subcategory": "places_and_spaces",
"release_date": "August 2024",
"source_label": "Data from Berkshire, Buckinghamshire and Oxfordshire Wildlife Trust.",
"source": "",
"source_type": "xlsx",
"data_url": "",
"table": "areadata",
"default_value": 10,
"exclude_countries": ["Scotland", "Northern Ireland"],
"comparators": DataSet.numerical_comparators(),
"unit_type": "raw",
"unit_distribution": "people_in_area",
"fill_blanks": False,
},
"col": "Total_Members",
}
}

def get_dataframe(self):
df = pd.read_excel(self.data_file)
df = df.astype({self.get_cons_col(): "str"})
return df
Loading