I am trying to merge two dataframes with a single column. I have looked for the solution in other questions, but without success.
Given the dataframes
import pandas as pd
df1 = pd.DataFrame({'x': [1, 2, 3, 4]})
df2 = pd.DataFrame({'x': [1, 2, 3, 5, 6]}
the desired output is
x_1 | x_2
1   | 1
2   | 2
3   | 3
4   | NaN
NaN | 5
NaN | 6
How can I achieve this result using pandas?
If I understand correctly, I cannot exploit either the column itself or the indexes to use pd.merge.
I could not get the result even using pd.concat([df1, df2], axis=1).
Thank you for your time and help
