Skip to content

Commit

Permalink
DATASET: Christian aid campaign organisers
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-griffen committed Dec 19, 2023
1 parent 99e7a05 commit b8a3aa7
Showing 1 changed file with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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 number of Christian Aid campaign organisers per constituency"
)

data_file = (
settings.BASE_DIR
/ "data"
/ "Christian Aid climate campaign organisers - Data.csv"
)
cons_row = "Constituency"
message = "Importing Christian Aid climate campaign organisers data"
uses_gss = False

defaults = {
"data_type": "integer",
"category": "movement",
"subcategory": "supporters_and_activists",
"description": "Number of Christian Aid campaign organisers per constituency.",
"release_date": "February 2023",
"source_label": "Data from Christian Aid.",
"source": "https://www.christianaid.org.uk/",
"source_type": "google sheet",
"table": "areadata",
"default_value": 1,
"data_url": "",
"unit_type": "raw",
"unit_distribution": "people_in_area",
"comparators": DataSet.numerical_comparators(),
}

data_sets = {
"constituency_foe_activists_count": {
"defaults": defaults,
"col": "organisers",
},
}

def get_dataframe(self):
df = pd.read_csv(self.data_file)
df = (
df.groupby("Constituency")
.count()
.reset_index()
.rename(columns={"Postcode": "organisers"})
)
return df

def get_label(self, defaults):
return f"Number of Christian Aid climate campaign organisers"

def delete_data(self):
AreaData.objects.filter(data_type__in=self.data_types.values()).delete()

0 comments on commit b8a3aa7

Please sign in to comment.