Skip to content

BUG: RecursionError when aligning column MultiIndex #33765

Closed
@epizut

Description

@epizut
  • 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.


When trying to do arithmetic on two dataframes with a common MultiIndex level, I am having a max recursion error.
Please note that if using string column names (ie: labels) instead of ints, I have no recursion error but still a buggy NaN result.

df1 = pd.DataFrame([[1, 2, 3]], columns=['Level1', 'Level2', 'Value'])
df1 = df1.set_index(['Level1', 'Level2']).T
df1

image

df2 = pd.DataFrame([[1, 3]], columns=['Level1', 'Value'])
df2 = df2.set_index(['Level1']).T
df2

image

df1 - df2

RecursionError on atlest pandas 1.0.2 and 1.0.3

image

Expected Output, working fine on pandas 1.0.1

image

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.8.2.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 61 Stepping 4, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252

pandas : 1.0.3
numpy : 1.18.3
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 41.2.0
Cython : None
pytest : 5.4.1
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.13.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.2.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.4.1
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds TestsUnit test(s) needed to prevent regressionsNumeric OperationsArithmetic, Comparison, and Logical operations

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions