Here's the simple Pandas data frame I'm using:
>>> df2
Name Day Score
0 Allen 1 25
5 Allen 3 9
What I'm trying to do is generate a list of Allen's scores, and also signal days when there is no score for all days from 1 to 5. Here's what I've been able to do:
>>> [df2[df2['Day']==i]['Score'].values[0] if i in list(df2['Day']) else None for i in range(1,6)]
[25, None, 9, None, None]
Surely there's a less clunky way to do this? What is it?
On a related note, I'd like to do this for each person in a larger data frame. What's the best way to do that? For now all I can think of is using apply with the expression above, but again that seems clunkier than this should have to be. Thanks for any suggestions!