question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

index changed after merge

See original GitHub issue
left_kdf = ks.DataFrame({'A': [1, 2]}, index = ['zero', 'one'])
left_kdf
         A
zero   1
one    2

right_kdf = ks.DataFrame({'B': ['x', 'y']}, index=['one', 'two'])
right_kdf
         B
one    x
two    y

left_kdf.merge(right_kdf, left_index=True, right_index=True)
       A     B
0     2     x

Index is changed. Expected answer is

left_kdf.merge(right_kdf, left_index=True, right_index=True)
       A     B
one     2     x

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
RainFungcommented, Jun 8, 2019

Looks like something worth fixing to me. I can create a PR for this later today.

Hello floscha. If you fix this, i can add some simple function like join,reindex based on merge easily.

0reactions
floschacommented, Jun 11, 2019

There was another corner case I was missing but it should be working now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to keep index when using pandas merge - Stack Overflow
I would like to merge two DataFrames , and keep the index from the first frame as the index on the merged dataset....
Read more >
pandas.merge — pandas 1.5.2 documentation
The join is done on columns or indexes. If joining columns on columns, the DataFrame indexes will be ignored. Otherwise if joining indexes...
Read more >
How to keep index when using pandas merge?
We want to set the index after merging according to our wish. For this purpose, we will reset the index at the time...
Read more >
Pandas: Merge - Datacomy
How to Keep index when using Pandas Merge ... By default, Pandas merge creates a new integer index for the merged DataFrame. If...
Read more >
Pandas Merge DataFrames on Index - Spark by {Examples}
In this article, I will explain how to merge two pandas DataFrames by index using merge() , concat() and join() methods with examples....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found