I have the below json from which I am trying to count the occurrence of tags like Latin America in Python. As it appears twice in, it should return 2 for "Latin America" and 1 for "Mexico", "Health" and "Costa Rica".
{
"AlJazeera_data": [
{
"name": "Mexico City hospitals reaching breaking point",
"url": "https://www.aljazeera.com/news/",
"tags": [
"Latin America",
"Mexico",
"Health"
],
"author": "Manuel Rapalo"
},
{
"name": "Football matches resume in Costa Rica as virus curbs ease",
"url": "https://www.aljazeera.coml",
"tags": [
"Latin America",
"Costa Rica"
],
"author": "Manuel Rapalo"
}]
}
Using this code:
import json
from collections import Counter
with open('../../Resources/Aljazeera.json') as f:
data = json.load(f)
for item in data['AlJazeera_data']:
for t in item['tags']:
print(t)
I get the output of the list of all tags, but I am stuck at calculating the count for all of the tags.