Skip to content
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

BUG: DataFrame.any() inconsistent with other methods #57087

Closed
3 tasks done
caneff opened this issue Jan 26, 2024 · 5 comments · Fixed by #58122
Closed
3 tasks done

BUG: DataFrame.any() inconsistent with other methods #57087

caneff opened this issue Jan 26, 2024 · 5 comments · Fixed by #58122
Labels
API - Consistency Internal Consistency of API/Behavior good first issue Reduction Operations sum, mean, min, max, etc.

Comments

@caneff
Copy link
Contributor

caneff commented Jan 26, 2024

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 = pd.DataFrame({'x':[1,2,3],'y':[1,2,3]})

df.all(0) # Positioned arg for axis is allowed.
df.any(0) # Positioned arg for axis not allowed.

Issue Description

The any method has a keyword only restriction for its arguments. The all method doesn't.

Expected Behavior

any and all should be consistent. To my POV any seems to be doing the right thing, while all (and other similar methods without a restriction and default arguments only, min, max etc) seems to be going against what Pandas has been moving toward where all arguments with defaults tend to fall on the keyword only side of the argument list.

Which is correct?

Installed Versions

INSTALLED VERSIONS

commit : b5a963c
python : 3.11.7.final.0
python-bits : 64
OS : Linux
OS-release : 6.5.13-1rodete1-amd64
Version : #1 SMP PREEMPT_DYNAMIC Debian 6.5.13-1rodete1 (2023-12-06)
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 3.0.0.dev0+172.gb5a963c872
numpy : 1.26.3
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 65.5.0
pip : 23.3.2
Cython : 3.0.5
pytest : 7.4.4
hypothesis : 6.97.0
sphinx : 7.2.6
blosc : None
feather : None
xlsxwriter : 3.1.9
lxml.etree : 5.1.0
html5lib : 1.1
pymysql : 1.4.6
psycopg2 : 2.9.9
jinja2 : 3.1.3
IPython : 8.20.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : 1.3.7
dataframe-api-compat : None
fastparquet : 2023.10.1
fsspec : 2023.12.2
gcsfs : 2023.12.2post1
matplotlib : 3.8.2
numba : 0.58.1
numexpr : 2.9.0
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : 15.0.0
pyreadstat : 1.2.6
python-calamine : None
pyxlsb : 1.0.10
s3fs : 2023.12.2
scipy : 1.12.0
sqlalchemy : 2.0.25
tables : 3.9.2
tabulate : 0.9.0
xarray : 2024.1.1
xlrd : 2.0.1
zstandard : 0.22.0
tzdata : 2023.4
qtpy : None
pyqt5 : None

@caneff caneff added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 26, 2024
@rhshadrach rhshadrach added Reduction Operations sum, mean, min, max, etc. Needs Discussion Requires discussion from core team before further action API - Consistency Internal Consistency of API/Behavior and removed Needs Triage Issue that has not been reviewed by a pandas team member Bug labels Jan 26, 2024
@rhshadrach
Copy link
Member

Thanks for the report. I'd favor keyword-argument only, but I think this needs a bit more discussion first.

@WillAyd
Copy link
Member

WillAyd commented Jan 26, 2024

I am also +1 to keyword-argument only

@twoertwein
Copy link
Member

+1 for keyword-only as well. I already changed a couple of methods in this typing PR #56739 when writing overloads depended on axis.

Many users would get the deprecation warning as even some tests/docs call those methods with positional arguments (seems not uncommon).

@rhshadrach rhshadrach added good first issue and removed Needs Discussion Requires discussion from core team before further action labels Jan 27, 2024
@aidoskanapyanov
Copy link
Contributor

Hi, can I work with this issue?

@twoertwein
Copy link
Member

Hi, can I work with this issue?

It might be good to wait until/if this #56739 gets merged as it has already changed many of those methods to keyword-only (I'm sure there might be more that I did not cover).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior good first issue Reduction Operations sum, mean, min, max, etc.
Projects
None yet
5 participants