Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: PerformanceWarning when merging dataframes with multiindex columns and indicator option #49325

Open
2 of 3 tasks
fjaragones opened this issue Oct 26, 2022 · 0 comments
Open
2 of 3 tasks
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@fjaragones
Copy link

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

df_one=pd.DataFrame({'A':['a','b'],'B':[1,2]})
df_two=pd.DataFrame({'A':['b','c'],'B':[3,4]})

df_one.columns=pd.MultiIndex.from_product([['one'],df_one.columns])
df_two.columns=pd.MultiIndex.from_product([['two'],df_two.columns])
df=pd.merge(df_one,df_two,how='outer',left_on=[('one','A')],right_on=[('two','A')],indicator=True)

Issue Description

When merging two dataframes with multiindex columns, if indicator is set to True, pandas shows:

PerformanceWarning: dropping on a non-lexsorted multi-index without a level parameter may impact performance.

If indicator is set to False, no warning is shown.

Expected Behavior

The expected behavior would be the execution of the code without the warning.

Installed Versions

INSTALLED VERSIONS ------------------ commit : 91111fd python : 3.9.13.final.0 python-bits : 64 OS : Linux OS-release : 5.15.0-52-generic Version : #58~20.04.1-Ubuntu SMP Thu Oct 13 13:09:46 UTC 2022 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : en_US.UTF-8 LANG : en_US.UTF-8 LOCALE : en_US.UTF-8

pandas : 1.5.1
numpy : 1.22.4
pytz : 2022.5
dateutil : 2.8.2
setuptools : 65.3.0
pip : 22.2.2
Cython : 0.29.32
pytest : 7.1.3
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.5.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : 1.3.5
brotli :
fastparquet : None
fsspec : 2022.10.0
gcsfs : None
matplotlib : 3.6.0
numba : 0.55.2
numexpr : 2.8.3
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.9.1
snappy : None
sqlalchemy : 1.4.41
tables : 3.7.0
tabulate : None
xarray : 2022.10.0
xlrd : 2.0.1
xlwt : None
zstandard : None
tzdata : None

@fjaragones fjaragones added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

1 participant