Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas Outer merge
#2
Can't see how to get what you want, but somewhere near it.

Given

Output:
df1 col1 col2 0 1 A 1 1 B 2 2 C 3 5 Z 4 4 Q
and

Output:
df2 col1 col2 0 1 A 1 1 B 2 2 E 3 3 X 4 4 R 5 4 S
df3 = df1.merge(df2, how="outer", left_index=True, right_index=True, suffixes=('_left', '_right'))
df4 = df3[['col2_left', 'col2_right']]

Output:
df4 col2_left col2_right 0 A A 1 B B 2 C E 3 Z X 4 Q R 5 NaN S
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,343 Jul-01-2022, 06:34 AM
Last Post: SharonDutton
  Unindent does not match any outer intendation level -error MaartenRo 3 2,386 Jun-28-2020, 11:46 AM
Last Post: MaartenRo
  Merge CSV Column using Pandas Data Frames davidlang 1 2,715 May-01-2020, 02:43 PM
Last Post: klllmmm
  HELP! unindent does not match any outer indentation level blackjesus24 2 2,079 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,619 Jan-01-2019, 10:52 AM
Last Post: the_fire_pharaoh
  Outer loop not running ted_gress 2 3,420 Aug-25-2018, 07:56 AM
Last Post: volcano63
  unindent does not match any outer indentation level tonyk334 4 5,174 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