Skip to content

BUG: Regression on np.logical_or, it behaves erraticly from 2.0, breaking backwards compatibility #54416

@PabloRuizCuevas

Description

@PabloRuizCuevas

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 numpy as np import pandas as pd a = pd.DataFrame({"or":[False,True], "a":[True,True], "b":[True, False]}) # fails with: ValueError: cannot reindex on an axis with duplicate labels np.logical_or(a[["a","b"]], a[2*["or"]]) # Erratic unpredictable behaviour with no fail :( np.logical_or(a[["a","b"]], a[["or","a"]])

Issue Description

This used to work in pandas 1.x as a element wise logical operation, now is not working anymore. Even worst in some cases may be completely overlooked as it doesn't raise errors but another df with mixed nans and booleans

Expected Behavior

logical element wise operation that returns two colums with booleans

Installed Versions

INSTALLED VERSIONS

commit : 0f43794
python : 3.11.2.final.0
python-bits : 64
OS : Linux
OS-release : 6.2.0-20-generic
Version : #20-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr 6 07:48:48 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

Metadata

Metadata

Assignees

Labels

BugCompatpandas objects compatability with Numpy or Python functionsRegressionFunctionality that used to work in a prior pandas versionufuncs__array_ufunc__ and __array_function__

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions