Skip to content

BUG: DataFrame.dropna must not allow to set both how= and thresh= parameters #46575

Closed
@arnaudlegout

Description

@arnaudlegout

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

In [62]: p = pd.DataFrame([[1, 2, np.nan], [3, np.nan, np.nan], [7, 5, np.nan]])

In [63]: p
Out[63]:
   0    1   2
0  1  2.0 NaN
1  3  NaN NaN
2  7  5.0 NaN

In [75]: p.dropna(how='all', axis=0)
Out[75]:
   0    1   2
0  1  2.0 NaN
1  3  NaN NaN
2  7  5.0 NaN

In [76]: p.dropna(how='all', thresh=2, axis=0)
Out[76]:
   0    1   2
0  1  2.0 NaN
2  7  5.0 NaN

Issue Description

DataFrame.dropna has two incompatible parameters thresh and how, setting them together must raise an exception. Currently, when they are both set, thresh preempts on how.

Expected Behavior

Setting both thresh and how on DataFrame.dropna must raise an exception. The documentation must be updated accordingly.

Installed Versions

In [77]: pd.show_versions()

INSTALLED VERSIONS

commit : 06d2301
python : 3.10.0.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19044
machine : AMD64
processor : Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : fr_FR.cp1252

pandas : 1.4.1
numpy : 1.21.5
pytz : 2021.3
dateutil : 2.8.2
pip : 21.2.4
setuptools : 58.0.4
Cython : 0.29.25
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.8.0
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.3
IPython : 8.1.1
pandas_datareader: 0.10.0
bs4 : None
bottleneck : 1.3.2
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.5.1
numba : 0.55.0
numexpr : 2.8.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 7.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.7.3
sqlalchemy : 1.4.27
tables : None
tabulate : 0.8.9
xarray : None
xlrd : None
xlwt : None
zstandard : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsError ReportingIncorrect or improved errors from pandasMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions