Given this object:
{
"script": "Georgian",
"id": 7,
"script_family": "European",
"direction": "LTR",
"num_languages": 11,
"type": "Alphabet",
"date": 500,
"Continent": ""
},
{
"script": "Armenian",
"id": 8,
"script_family": "European",
"direction": "RTL",
"num_languages": 1,
"type": "Alphabet",
"date": 500,
"Continent": ""
},
{
"script": "Tamil",
"id": 9,
"script_family": "Indic",
"direction": "LTR",
"num_languages": 6,
"type": "Syllabary",
"date": 800,
"Continent": ""
},
{
"script": "Tibetan",
"id": 10,
"script_family": "Central Asian",
"direction": "LTR",
"num_languages": 45,
"type": "Abugida",
"date": 800,
"Continent": ""
},
{
"script": "Khmer",
"id": 11,
"script_family": "Mainland Southeast Asian",
"direction": "LTR",
"num_languages": 3,
"type": "Abugida",
"date": 900,
"Continent": ""
},
I want to make an array of objects that looks like this where it is grouped by date and contains the number of scripts that appear in that date for each script family.
data = [
{date: 500, European: 2}
{date: 800, Indic: 1, Central Asia: 1}
...
]
Where sometimes a data can have multiple script families.
I tried this code:
family = data.groupby(['date', 'script_family'])['script_family'].count()
But when I export it as a csv, I only get the count of "script_families" though I want each script_family that appears at the specific date to be set to the number of scripts.
date script_family
-400 European 1
-300 East Asian 1
-200 Middle Eastern 1
-100 European 1
500 African 1
European 2
600 Middle Eastern 1
800 Central Asian 1
Indic 1
900 East Asian 1
European 1
Indic 3
Mainland Southeast Asian 1
1000 Indic 1
1100 Indic 2
Mainland Southeast Asian 1
1200 Indic 1
1300 Central Asian 1
Mainland Southeast Asian 1
...