-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
import member data from Sussex Wildlife Trust
Fixes #555
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |