Skip to content

Commit

Permalink
DATASET: Save the children supporters
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-griffen committed Nov 23, 2023
1 parent ae67f86 commit a04c934
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions hub/management/commands/import_save_the_children_supporter_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from django.conf import settings

import pandas as pd

from hub.models import AreaData, DataSet

from .base_importers import BaseImportFromDataFrameCommand


class Command(BaseImportFromDataFrameCommand):
help = (
"Import data about the number of Save the Children supporters per constituency"
)

message = "importing Save the Children shop count"
uses_gss = False
cons_row = "CONSTITUENCY"
data_file = (
settings.BASE_DIR / "data" / "2022_Campaigning_Actions_By_Constituency 1.csv"
)

defaults = {
"label": "Number of Save the Children supporters",
"description": "The number of Save The Children supporters per constituency.",
"data_type": "integer",
"category": "movement",
"subcategory": "supporters_and_activists",
"source_label": "Data from Save the Children.",
"release_date": "2022",
"source": "https://www.savethechildren.org.uk/",
"source_type": "csv",
"data_url": "",
"table": "areadata",
"default_value": 10,
"comparators": DataSet.numerical_comparators(),
"unit_type": "raw",
"unit_distribution": "people_in_area",
}

data_sets = {
"save_the_children_supporter_count": {
"defaults": defaults,
"col": "NUMBER_OF_SUPPORTERS",
},
}

def get_dataframe(self):
df = pd.read_csv(self.data_file)
return df

def delete_data(self):
for data_type in self.data_types.values():
AreaData.objects.filter(data_type=data_type).delete()

0 comments on commit a04c934

Please sign in to comment.