-1

i want to include all columns from each dataset, how would i accomplish this?

Dataset1

Dataset2

john doe
  • 23
  • 3
  • 1
    please provide your data as text-based minimal reproducible example, explain the logic and the expected output – mozway May 10 '22 at 12:11

2 Answers2

0

If you provide more details of what you are looking for it would be easier to assist you, but IIUC this will give all columns and join them on the same column names

import pandas as pd

df_merge = pd.merge(df1, df2)
ArchAngelPwn
  • 2,891
  • 1
  • 4
  • 17
  • Do you know a way i can merge them, but instead of creating duplicate column values where there wasnt a column for that in the other set, it could be blank or unknown? – john doe May 10 '22 at 12:33
  • Without seeing more of your data in text form I really wouldn't be able to help unfortunately. I recommend you edit your original question to include the actual data and the expected results if you want additional support – ArchAngelPwn May 10 '22 at 12:42
0

You can do what ArchAngelPwn says or you can use left_on and right_on to know from which df is each column.

df = pd.merge(Dataset1, Dataset2, left_on="d1", right_on="d2")