I have two pandas data frames
df1 looks like this:
Column A | Column B |
---|---|
1000 | Company1 |
1001 | Company2 |
1002 | Company3 |
1003,1004 | Company4 |
df2 looks like this:
Column A | Column B | Column C |
---|---|---|
1000 | 2.1 | 2.1_Info1 |
1001 | 2.3 | 2.3_Info2 |
1002 | 2.1 | 2.1_Info1 |
1003 | 3 | 3_Info3 |
1004 | 6.1 | 6.1_Info4 |
1005 | 2.2 | 2.2_Info5 |
What I’m trying to do is check and see if the values from Column A in df1 is in Column A in df2. If it is, I would like to take the information from Column C in df2 and create a new column in df1 with the values from column C in df2 so it would look like this:
output:
Column A | Column B | New Column |
---|---|---|
1000 | Company1 | 2.1_Info1 |
1001 | Company2 | 2.3_Info2 |
1002 | Company3 | 2.1_Info1 |
1003,1004 | Company4 | 3_Info3, 6.1_Info4 |
——– | ——– |
I’m sorry if this sounds confusing, any help on this would be GREATLY appreciated. Thank you!
I’ve tried merging, and using for loops but many of my records get discarded and i’m trying to keep all records.