Description
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
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