I have follow simple DataFrame - df
:
0
0 1
1 2
2 3
Once I try to create a new columns and assign some values for them, as example below:
df['col2', 'col3'] = [(2,3), (2,3), (2,3)]
I got following structure
0 (col2, col3)
0 1 (2, 3)
1 2 (2, 3)
2 3 (2, 3)
However, I am looking a way to get as here:
0 col2, col3
0 1 2, 3
1 2 2, 3
2 3 2, 3
Looks like solution is simple:
df['col2'], df['col3'] = zip(*[(2,3), (2,3), (2,3)])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With