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*

pandas python: concet/merge/join 2 dfs on index

I have two dfs which I would like to concat on index to make a multiindex df.

df1 = pd.DataFrame({'value1': [1.1,2,3],
                    })

df2 = pd.DataFrame({'value1': [21,24,35],
                    })

Expected output

    value1
0      1.1
       21
1      2.0
       24
2      3.0
       35
3      4.0

my failed attempt:

df = pd.concat([df1, df2], axis=0)

output

   value1
0     1.1
1     2.0
2     3.0
0    21.0
1    24.0
2    35.0

Answer*

Cancel