How do I copy multiple columns from one dataframe to a new dataframe? it would also be nice to rename them at the same time
df2['colA']=df1['col-a'] #This works
df2['colA', 'colB']=df1['col-a', 'col-b'] #Tried and Failed
Thanks
You have to use double brackets:
df2[['colA', 'colB']] = df1[['col-a', 'col-b']]
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