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
# create dataframe
df1 = pd.DataFrame({'A': [0, 1, 2], 'B': [1, 2, 3]})
df1.columns.set_names('L1', inplace=True)
# create dataframe with multiindex in column
df2 = pd.DataFrame({('A', 'C'): [0, 0, 0], ('A', 'D'): [0, 0, 0]})
df2.columns.set_names(['L1', 'L2'], inplace=True)
# returns dataframe of nans
df1.add(df2)
# returns dataframe with valid values
df1.add(df2, level=0)
Problem description
In pandas 0.23.2 the behavior was correct where level=None was treated as level=0 and being broadcasted. However in pandas 1.0.3, it appears as though a bug got introduced.
Expected Output
Out[1]:
A
C D
0 0 0
1 1 1
2 2 2
Output of pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.6.final.0
python-bits : 64
OS : Linux
OS-release : 4.14.13-1.el7.elrepo.x86_64
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.0.3
numpy : 1.18.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.0.2
setuptools : 46.4.0.post20200518
Cython : 0.29.17
pytest : 5.4.2
hypothesis : None
sphinx : 3.0.3
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.5.0
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.13.0
pandas_datareader: None
bs4 : None
bottleneck : 1.3.2
fastparquet : None
gcsfs : None
lxml.etree : 4.5.0
matplotlib : 3.1.3
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.4.2
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.17
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : None
numba : 0.49.1