Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas Outer merge
#1
I have two data frames
dataframe 1
col1 col2
1 A
1 B
2 C
5 Z
4 Q

dataframe 2

col1 col2
1 A
1 B
2 E
3 X
4 R
4 S
I am performing an outer merge

merge = pd.merge(dataframe1, datagrame2, on="col1", how='outer')
I get

col1 col2_x col2_y
1 A A
1 A B
1 B A
1 B B
2 C E
5 Z NAN
3 NAN X
4 Q R
4 Q S

How do I get the output as below

col1 col2_x col2_y
1 A A
1 B B
2 C E
5 Z NAN
3 NAN X
4 Q R
4 Q S
Any help will be appreciated. Thank you
Reply


Messages In This Thread
Pandas Outer merge - by skollu826 - Apr-19-2024, 07:28 PM
RE: Pandas Outer merge - by Pedroski55 - Apr-20-2024, 12:53 PM
RE: Pandas Outer merge - by deanhystad - Apr-20-2024, 06:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  can Inner Class reference the Outer Class's static variable? raykuan 6 6,118 Jul-01-2022, 06:34 AM
Last Post: SharonDutton
  Unindent does not match any outer intendation level -error MaartenRo 3 2,331 Jun-28-2020, 11:46 AM
Last Post: MaartenRo
  Merge CSV Column using Pandas Data Frames davidlang 1 2,668 May-01-2020, 02:43 PM
Last Post: klllmmm
  HELP! unindent does not match any outer indentation level blackjesus24 2 2,017 Jan-29-2020, 08:00 AM
Last Post: blackjesus24
  unindent does not match any outer indentation level , How can i fix it the_fire_pharaoh 2 2,562 Jan-01-2019, 10:52 AM
Last Post: the_fire_pharaoh
  Outer loop not running ted_gress 2 3,376 Aug-25-2018, 07:56 AM
Last Post: volcano63
  unindent does not match any outer indentation level tonyk334 4 5,090 Mar-18-2018, 04:40 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020