Reputation: 11
I have a Dataframe as below:
2021-02-01 00:00:00
0 [0.22081292351898762, 0.22248217707309176, 0.2...
I'd like to change it to:
2021-02-01 00:00:00
0 0.22081292351898762
1 0.22248217707309176
2 0.2...
3 00000
Please give me some advises. Thank you.
Upvotes: 1
Views: 55
Reputation: 11
Sample:
data = {'my_column': [
[1, 2, 3],
[4, 5, 6],
]}
df = pd.DataFrame(data)
print(df)
my_column
0 [1, 2, 3]
1 [4, 5, 6]
Use explode
:
df_explode = df.explode('my_column', ignore_index=True)
print(df_explode)
my_column
0 1
1 2
2 3
3 4
4 5
5 6
Upvotes: 1