Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Concatenate two dfs with strings column by column

I have two tables df1 and df2.

print(df1)
    bar1 foo1
0    a   e
1    b   f
2    c   g

print(df2)
    bar2 foo2
0    x   l
1    y   m
2    z   n

I need to concatenate them column by column into one table with two columns.

I need this table:

     bar3  foo3
0    a x   e l
1    b y   f m
2    c z   g n

How can I do it using pandas?

Answer*

Cancel
0