---
# System prepended metadata

title: Convert ranking

---

# Convert ranking

```python=
from datetime import date

def convert_ranking_data(date_and_ranking):
    date_origin = date.fromisoformat(date_and_ranking[0]["date"])
    date_end = date.fromisoformat(date_and_ranking[-1]["date"])

    print("date origin: %s" % date_origin)
    print("date end: %s" % date_end)

    total_days = ((date_end - date_origin).days + 1)

    print("total days: %d" % total_days)

    ranking_data = [None] * total_days
    for dr in date_and_ranking:
        date_current = date.fromisoformat(dr["date"])
        index = (date_current - date_origin).days
        ranking_data[index] = int(dr["ranking"])

    return ranking_data


```