how can I initialize multiple columns in a single instance in an existing pandas DataFrame object? I can initialize single column at an instance, this way:
df = pd.DataFrame({'a':[1,2,3],'b':[4,5,6]}, dtype='int')
df['c'] = 0
but i cannot do something like:
df[['c','d']] = 0 or
df[['c']['d']] = 0
is there a way i can achieve this?
I prefer this solution.
df = df.assign(**{'c': 0, 'd': 0})
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