Currently I have a table that looks like this
ID Previous_Injuries Currently_Injured Injury_Type
1 Nan 0 Nan
1 Nan 1 Ankle
1 Nan 0 Nan
1 Nan 1 Wrist
1 Nan 0 Nan
1 Nan 1 Leg
1 Nan 0 Nan
2 Nan 1 Leg
2 Nan 0 Nan
I would like to add to the Previous Injuries Column and make my table look like this:
ID Previous_Injuries Currently_Injured Injury_Type
1 Nan 0 Nan
1 Nan 1 Ankle
1 [Ankle] 0 Nan
1 [Ankle] 1 Wrist
1 [Ankle,Wrist] 0 Nan
1 [Ankle,Wrist] 1 Leg
1 [Ankle,Wrist,Leg] 0 Nan
2 Nan 1 Leg
2 [Leg] 0 Nan
How can I achieve this sort of a column in pandas? And is it best to do it in the form of a list?
Thanks!
lists (or other objects) in a DataFrame is inefficient and makes other manipulations much more complicated. Though sometimes it can be fine if your data aren't huge. What do you need to do with this information after?