BUG: comparison warning with NaN when DataFrame/Series broadcasting · Issue #16378 · pandas-dev/pandas (original) (raw)

Code Sample

df = pd.DataFrame({'A' : [np.nan, 2.0, np.nan]}) df A 0 NaN 1 2.0 2 NaN x = pd.Series([1, 1, 1]) x 0 1 1 1 2 1 dtype: int64 df.clip_lower(x, axis=0) /usr/local/lib/python3.5/dist-packages/pandas/core/ops.py:1253: RuntimeWarning: invalid value encountered in greater_equal result = op(x, y) A 0 NaN 1 2.0 2 NaN

df.clip_lower(x, axis=0) A 0 NaN 1 2.0 2 NaN

Problem description

So the RuntimeWarning is only thrown the first time the clip is called. But not on subsequent times. This is inconsistent.

Expected Output

I propose to suppress this warning altogether as the triggering use cases seem to be completely common and fully legit.

Output of pd.show_versions()

>>> pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-75-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.20.1
pytest: None
pip: 9.0.1
setuptools: 20.7.0
Cython: None
numpy: 1.12.1
scipy: 0.19.0
xarray: None
IPython: 6.0.0
sphinx: None
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.0.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: 0.7.3
lxml: None
bs4: None
html5lib: 0.999999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
s3fs: None
pandas_gbq: None
pandas_datareader: None