I have a dataframe:
df = pd.DataFrame([
{"node":"A","month":1,"val":-77},
{"node":"A","month":2,"val":0},
{"node":"B","month":1,"val":-16},
{"node":"B","month":2,"val":0}
])
I'd like to modify this so that each month is within the same row and the month value is the key to the value of 'val':
df = pd.DataFrame([
{"node":"A", 1: -77, 2: 0},
{"node":"B", 1: -16, 2: 0}
])