Skip to content

BUG: Series' lt, gt, le, ge, ne, eq methods are raising a downcasting warning even though the Series' dtype is float64. #59415

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
2 of 3 tasks
MauroAbidalCarrer opened this issue Aug 5, 2024 · 2 comments
Assignees
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Warnings Warnings that appear or should be added to pandas

Comments

@MauroAbidalCarrer
Copy link

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
import numpy as np



```python
nan_s = pd.Series([np.nan] * len(s), dtype="float")
nan_s.dtype
nan_s.lt(0, fill_value=False)
nan_s.gt(0, fill_value=False)
nan_s.le(0, fill_value=False)
nan_s.ge(0, fill_value=False)
nan_s.ne(0, fill_value=False)
nan_s.eq(0, fill_value=False)
/tmp/ipykernel_127420/829981878.py:1: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  nan_s.lt(0, fill_value=False)
/tmp/ipykernel_127420/829981878.py:2: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  nan_s.gt(0, fill_value=False)
/tmp/ipykernel_127420/829981878.py:3: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  nan_s.le(0, fill_value=False)
/tmp/ipykernel_127420/829981878.py:4: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  nan_s.ge(0, fill_value=False)
/tmp/ipykernel_127420/829981878.py:5: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  nan_s.ne(0, fill_value=False)
/tmp/ipykernel_127420/829981878.py:6: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  nan_s.eq(0, fill_value=False)





0    True
1    True
2    True
3    True
4    True
5    True
6    True
7    True
dtype: bool


### Issue Description

The lt, gt, le, ge, ne, eq methods are raising a downcasting warning even though the Series' dtype is float64.
This issue only seems to occur when the series is full nans and that fill_value is specified.

### Expected Behavior

The methods should not raise a downcast warning.
This is my first issue so hopefully this is an appropriate expectation. 

### Installed Versions

    INSTALLED VERSIONS
    ------------------
    commit                : d9cdd2ee5a58015ef6f4d15c7226110c9aab8140
    python                : 3.11.3.final.0
    python-bits           : 64
    OS                    : Linux
    OS-release            : 6.1.0-23-amd64
    Version               : #1 SMP PREEMPT_DYNAMIC Debian 6.1.99-1 (2024-07-15)
    machine               : x86_64
    processor             : 
    byteorder             : little
    LC_ALL                : None
    LANG                  : en_US.UTF-8
    LOCALE                : en_US.UTF-8
    
    pandas                : 2.2.2
    numpy                 : 1.26.4
    pytz                  : 2024.1
    dateutil              : 2.9.0
    setuptools            : 71.0.4
    pip                   : 23.1.2
    Cython                : None
    pytest                : None
    hypothesis            : None
    sphinx                : None
    blosc                 : None
    feather               : None
    xlsxwriter            : None
    lxml.etree            : None
    html5lib              : None
    pymysql               : None
    psycopg2              : None
    jinja2                : 3.1.3
    IPython               : 8.21.0
    pandas_datareader     : None
    adbc-driver-postgresql: None
    adbc-driver-sqlite    : None
    bs4                   : 4.12.3
    bottleneck            : None
    dataframe-api-compat  : None
    fastparquet           : None
    fsspec                : 2023.6.0
    gcsfs                 : None
    matplotlib            : 3.8.2
    numba                 : 0.58.1
    numexpr               : None
    odfpy                 : None
    openpyxl              : None
    pandas_gbq            : None
    pyarrow               : 15.0.0
    pyreadstat            : None
    python-calamine       : None
    pyxlsb                : None
    s3fs                  : 2023.6.0
    scipy                 : 1.11.4
    sqlalchemy            : None
    tables                : None
    tabulate              : 0.9.0
    xarray                : None
    xlrd                  : None
    zstandard             : None
    tzdata                : 2023.4
    qtpy                  : None
    pyqt5                 : None
@MauroAbidalCarrer MauroAbidalCarrer added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 5, 2024
@KevsterAmp
Copy link
Contributor

Take

@rhshadrach
Copy link
Member

rhshadrach commented Aug 5, 2024

Thanks for the report. You are specifying the fill_value as the Boolean False. Specify it as 0.0 instead and you will not see the warning.

Warning in the OP example looks correct to me. If you think this is mistaken, comment below as to why and we can reopen.

@rhshadrach rhshadrach added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Warnings Warnings that appear or should be added to pandas and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Warnings Warnings that appear or should be added to pandas
Projects
None yet
Development

No branches or pull requests

3 participants