Skip to content

Commit

Permalink
import member data from Sussex Wildlife Trust
Browse files Browse the repository at this point in the history
Fixes #555
  • Loading branch information
struan committed Jun 17, 2024
1 parent ef01ffa commit 9aa1dc6
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions hub/management/commands/import_sussex_wt_member_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from django.conf import settings

import pandas as pd

from hub.models import DataSet

from .base_importers import BaseImportFromDataFrameCommand


class Command(BaseImportFromDataFrameCommand):
help = "Import Sussex Wildlife Trust member counts for post 2024 constituencies"

message = "importing sussex wildlife trust member counts"
cons_row = "constituency"
cons_col = "constituency"
data_file = settings.BASE_DIR / "data" / "sussex_wt_member_counts.csv"
uses_gss = False

area_type = "WMC23"

data_sets = {
"sussex_wt_members": {
"defaults": {
"label": "Sussex Wildlife Trust members",
"data_type": "integer",
"category": "movement",
"subcategory": "places_and_spaces",
"release_date": "May 2024",
"source_label": "Data from Sussex Wildlife Trust.",
"source": "",
"source_type": "csv",
"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": "sussex_wt_members_may_2024",
}
}

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

0 comments on commit 9aa1dc6

Please sign in to comment.