I the following pandas dataframe:
import pandas as pd
df = pd.DataFrame({'Year': [2023, 2024, 2022,2022, 2023,2025,2024,2025,2022,2023],'Name': ['John', 'Jim', 'John','Jim', 'John','Jim','John','Jim','John','Jim']
,'Month': ['Jan', 'Jan', 'Feb','Jan', 'Jan','Feb','Jan','Jan','Feb','Feb'],'Day': [1, 2, 5,6, 7,4,8,24,13,15]})
df
which looks like:
I am trying to convert this to a dictionary/api format so it can be use in a get
request.
I need it in a format that is grouped by Name
, then Year
, then Month
and the values are Day
. My front end output expected is this
By any help to create the dictionary/api view to achieve this would be fantastic. Thanks very much