I have a Pandas series like this
pd.DataFrame({"name": ['John','Mary','Tommy'],
"time": ['"data": [{"t": "16:50"},{"t": "17:05"}]',
'"data": [{"t": "16:10"}, {"t": "17:11"}, {"t": "17:12"}]',
np.nan]})
Now when it comes to data it would look like this
name time
0 John "data": [{"t": "16:50"},{"t": "17:05"}]
1 Mary "data": [{"t": "16:10"}, {"t": "17:11"}, {"t":...
2 Tommy NaN
In column time is a dictionary (in string format) and it contains a list (max 3 items, sometimes it is NaN
). As the max list size is known so I would like to flatten my data into the following.
name time1 time2 time3
0 John 16:50 17:05 NaN
1 Mary 16:10 17:11 17:12
2 Tommy NaN NaN NaN
Except using for loop, I am not sure how to do that in Panda's way. Thanks in advance.