Answers for "add multiple columns to dataframe from another dataframe r"

0

pandas assign multiple columns at once

df = pd.DataFrame({'col1':[0,1,2], 'col2':[0,1,2], 'col3':[0,1,2]})

df
   col1  col2  col3
0     0     0     0
1     1     1     1
2     2     2     2

df['col1'], df['col2'], df['col3'] = zip(*df.apply(lambda r: (1, 2, 3), axis=1))

df
   col1  col2  col3
0     1     2     3
1     1     2     3
2     1     2     3
Posted by: Guest on January-12-2022
0

r add multiple column to dataframe

<dataframe> <- <dataframe> %>%
  mutate(<column_name> = <insert what you want bro>, <column_name_2> = <insert what you want bro>)
Posted by: Guest on February-26-2021

Code answers related to "add multiple columns to dataframe from another dataframe r"

Browse Popular Code Answers by Language