Skip to content

BUG: Correctly specified broadcasting leads to a RecursionError #44290

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

Closed
1 of 3 tasks
rs2 opened this issue Nov 2, 2021 · 2 comments
Closed
1 of 3 tasks

BUG: Correctly specified broadcasting leads to a RecursionError #44290

rs2 opened this issue Nov 2, 2021 · 2 comments
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@rs2
Copy link
Contributor

rs2 commented Nov 2, 2021

  • 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 master branch of pandas.

Reproducible Example

import pandas as pd                                                                                                                          
a = pd.DataFrame(data=[[21] * 3, [22] * 3], columns=pd.MultiIndex.from_tuples([(1, 10), (2, 10), (3, 11)], names=['foo', 'bar']))            
b = pd.DataFrame(data=[[31] * 2, [32] * 2], columns=pd.Int64Index([10, 11], name='bar'))                                                     
print(a)                                                                                                                                            
print(b)
print(b + a)  # This works, but returns an incorrect result: all NaNs
print(a + b)  # This raises a RecursionError

Issue Description

    755             self, other, op, axis, default_axis, fill_value, level
    756         ):
--> 757             return _frame_arith_method_with_reindex(self, other, op)
    758 
    759         other = _align_method_FRAME(self, other, axis)

RecursionError: maximum recursion depth exceeded while calling a Python object

Expected Behavior

In [6]: b + a
Out[6]:
foo   1   2   3
bar  10  10  11
0    52  52  52
1    54  54  54

In [7]: a + b
Out[7]:
foo   1   2   3
bar  10  10  11
0    52  52  52
1    54  54  54

Installed Versions

pandas : 1.0.5

@rs2 rs2 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 2, 2021
@rs2
Copy link
Contributor Author

rs2 commented Nov 2, 2021

Closed by #33765

@rs2 rs2 closed this as completed Nov 2, 2021
@rs2
Copy link
Contributor Author

rs2 commented Nov 2, 2021

Also see #25760

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