I have a dataset like this
index data data_list label
A i love pyhton. ['i love python.', [1,0]
pyhton very useful. 'python very useful.']
B i like tea. tea ['i like tea.','tea [0,1]
make me happy. make me happy.']
I want to arrange the dataset like below
index data data_list label
A i love pyhton. i love python. 1
pyhton very useful.
A i love pyhton. python very useful. 0
pyhton very useful.
B i like tea. tea i like tea. 0
make me happy.
B i like tea. tea tea make me happy. 1
make me happy.
But, i don't know how to solve this problem. Can anyone help, please. Thanks for your time.
What you want is something called, explode function.Which basically expands, the interable and creates a base index to which grouped by element row. Just do the following line of code.
df.explode(['data_list','label'])