'Change Dataset in Python [duplicate]
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.
Solution 1:[1]
You can try pandas.DataFrame.explode. Docs here.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | alexm |
