Adding column(s) from one dataframe to another python pandas
import pandas as pd
import io
data = """
ColumnA columnB columnC columnD
A B C D
A B C D
A B C D
"""
data1 = """
ColumnE columnF columnG
E F G
E F G
E F G
"""
df = pd.read_csv(io.StringIO(data), delimiter='\s+')
df1 = pd.read_csv(io.StringIO(data1), delimiter='\s+')
df['columnF'] = pd.Series(df1['columnF'])
print(df)
Will give you:
ColumnA columnB columnC columnD columnF
0 A B C D F
1 A B C D F
2 A B C D F
import pandas as pd
f_column = data2["columnF"]
data1 = pd.concat([data1,f_column], axis = 1)
data1
columnA columnB columnC columnF
0 a b c f
1 a b c f
2 a b c f