-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
Milestone
Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
import pandas as pd
idx1 = pd.Index([0, 0, 1])
idx2 = pd.Index([0, 1])
print(idx1.union(idx2))
# Int64Index([0, 0, 1], dtype='int64')
print(idx2.union(idx1))
# Int64Index([0, 0, 1], dtype='int64')
idx1 = pd.Index([1, 0, 0])
print(idx1.union(idx2))
# Int64Index([0, 0, 1], dtype='int64')
print(idx2.union(idx1))
# Int64Index([0, 1], dtype='int64')Problem description
In the fourth call idx2.union(idx1) one of the 0 is dropped. Meaning union() depends on the call order and on the index order, which seems buggy.
Expected Output
Int64Index([0, 0, 1], dtype='int64') for every print Statement
Output of pd.show_versions()
Details
master