File size: 301 Bytes
1551218 |
1 2 3 4 5 6 7 8 9 10 11 12 |
from typing import Dict, List
def build_timeline(docs: List[dict]) -> Dict[str, int]:
timeline: Dict[str, int] = {}
for d in docs:
year = d.get("date", "")[:4]
if not year.isdigit():
continue
timeline[year] = timeline.get(year, 0) + 1
return timeline |