I'm trying to add few list to an existing data. I'm not sure if I can do in easy and efficient way.
# df is already created with many columns.
# The lists lst1, lst2, lst3, lst4 will be added to df.
df['newcol1']=lst1
df['newcol2']=lst2
df['newcol3']=lst3
df['newcol4']=lst4
This works fine. Is there any better way like this?
# I tried following methods
df[['newcol1','newcol2','newcol3','newcol4']]=[lst1,lst2,lst3,lst4]
df[['newcol1','newcol2','newcol3','newcol4']]=list(zip(lst1,lst2,lst3,lst4))
df[['newcol1','newcol2','newcol3','newcol4']]=list(map(list,zip(lst1,lst2,lst3,lst4)))
All these methods do not work.
df[['newcol1','newcol2','newcol3','newcol4']]=?? # What should I write here?
I don't want to create new dataset and do pd.concat or use some apply function.
There must be a better way for df[['newcol1','newcol2','newcol3','newcol4']].