-
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.
- Loading branch information
1 parent
ad29b34
commit 47cdaf2
Showing
1 changed file
with
52 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,52 @@ | ||
from django.conf import settings | ||
|
||
import pandas as pd | ||
|
||
from hub.models import DataSet | ||
|
||
from .base_importers import BaseConstituencyGroupListImportCommand | ||
|
||
|
||
class Command(BaseConstituencyGroupListImportCommand): | ||
help = "Import Wildlife trust reserves" | ||
|
||
data_file = ( | ||
settings.BASE_DIR / "data" / "wildlife_trust_regions_in_constituencies.csv" | ||
) | ||
cons_row = "PCON19NM" | ||
uses_gss = False | ||
message = "Importing constituency Wildlife Trust regions data" | ||
|
||
data_sets = { | ||
"wildlife_trusts_regions": { | ||
"defaults": { | ||
"label": "Wildlife Trust Regions", | ||
"description": "The Wildlife Trust Region(s) that a constituency falls under.", | ||
"data_type": "json", | ||
"category": "place", | ||
"subcategory": "groups", | ||
"source_label": "Data from The Widlife Trusts", | ||
"source": "https://www.wildlifetrusts.org/", | ||
"source_type": "csv", | ||
"table": "areadata", | ||
"is_filterable": True, | ||
"comparators": DataSet.in_comparators(), | ||
}, | ||
"col": "Trust", | ||
} | ||
} | ||
group_data_type = "wildlife_trusts_regions" | ||
|
||
def get_df(self): | ||
return pd.read_csv(self.data_file, usecols=["Trust", "PCON19NM"]).rename( | ||
columns={"PCON19NM": "constituency"} | ||
) | ||
|
||
def get_group_json(self, row): | ||
return row[["Trust"]].dropna().rename({"Trust": "group_name"}).to_dict() | ||
|
||
def update_averages(self): | ||
pass | ||
|
||
def update_max_min(self): | ||
pass |