This commit is contained in:
MuslemRahimi 2024-10-20 21:33:44 +02:00
parent 04fbef17b4
commit cea17acfd5

View File

@ -242,6 +242,10 @@ def generate_geography_dataset(dataset):
date = item.get('date') date = item.get('date')
value = int(float(item.get('value', 0))) value = int(float(item.get('value', 0)))
year = int(date[:4])
if year < 2019:
continue # Skip this item if the year is less than 2019
# Replace country name if necessary # Replace country name if necessary
country_name = country_replacements.get(name, 'Other') country_name = country_replacements.get(name, 'Other')
@ -256,7 +260,7 @@ def generate_geography_dataset(dataset):
# Convert the aggregated data back into the desired list format # Convert the aggregated data back into the desired list format
dataset = [{'name': country, 'date': date, 'value': total_value} for (country, date), total_value in aggregated_data.items()] dataset = [{'name': country, 'date': date, 'value': total_value} for (country, date), total_value in aggregated_data.items()]
print(dataset)
dataset = aggregate_other_values(dataset) dataset = aggregate_other_values(dataset)
dataset = sorted( dataset = sorted(
dataset, dataset,