BUG: merge with MultiIndex including a CategoricalIndex returns wrong result when values are ordered specifically #36973
Labels
Categorical
Categorical Data Type
good first issue
MultiIndex
Needs Tests
Unit test(s) needed to prevent regressions
Reshaping
Concat, Merge/Join, Stack/Unstack, Explode
Milestone
Code Sample
output:
Problem description
The merge should not return NaN for the ('C', 'P1') value available in df2 for the left merge.
This happens only:
p
is Categorical: leaving the column as object/string gives the right resultordered
argument does not change the resultid
values are as such: changing the 'C' in 'E' or anything "above" gives the right result (!)Expected Output
First level of investigations
Using a debugger and following the code execution:
It seems it uses the wrong branch/case.
This is how far I can get.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 2a7d332
python : 3.8.3.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.18362
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : fr_FR.cp1252
pandas : 1.1.2
numpy : 1.19.2
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.3
setuptools : 41.2.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.5
pandas_gbq : None
pyarrow : 1.0.1
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : 3.6.1
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: