Skip to content

Unhandled warning from NumPy dev in median #22712

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
TomAugspurger opened this issue Sep 14, 2018 · 2 comments
Closed

Unhandled warning from NumPy dev in median #22712

TomAugspurger opened this issue Sep 14, 2018 · 2 comments
Labels
Compat pandas objects compatability with Numpy or Python functions Dependencies Required and optional dependencies

Comments

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Sep 14, 2018

In [1]: import pandas as pd

In [2]: import numpy as np

In [3]: x = np.random.randn(30, 4)

In [4]: x[5:10] = np.nan

In [5]: pd.DataFrame(x).median(1).head()
/Users/taugspurger/miniconda3/envs/travis-37-numpydev/lib/python3.7/site-packages/numpy/lib/function_base.py:3267: RuntimeWarning: All-NaN slice encountered
  r = func(a, **kwargs)
Out[5]:
0   -0.602415
1   -0.118699
2    0.744368
3   -0.993376
4   -0.304693
dtype: float64

In [6]: np.__version__
Out[6]: '1.16.0.dev0+88cbd3d'

Do we want to silence these?

Working around this in #22699

@TomAugspurger TomAugspurger added Compat pandas objects compatability with Numpy or Python functions Dependencies Required and optional dependencies labels Sep 14, 2018
@mroeschke
Copy link
Member

I don't imagine this is much of an issue anymore. On 1.18.1 no warning is issued. Closing for now but happy to reopen.

In [1]: np.__version__
Out[1]: '1.18.1'

In [2]: In [1]: import pandas as pd
   ...:
   ...: In [2]: import numpy as np
   ...:
   ...: In [3]: x = np.random.randn(30, 4)
   ...:
   ...: In [4]: x[5:10] = np.nan
   ...:
   ...: In [5]: pd.DataFrame(x).median(1).head()
Out[2]:
0   -0.155427
1   -0.317316
2    0.752829
3    0.366792
4   -0.155743
dtype: float64

@ivangvi
Copy link

ivangvi commented Jul 20, 2020

Hi! I stumbled across this issue while doing several aggregations, sum, mean and so on. Median gives me warning and I believe I'd like to avoid it. With the following line you should be able to reproduce the warning:

pd.DataFrame(data = {'a':[np.NaN,2,3],'b':[np.NaN,3,3]}).agg('median',axis = 1)

\lib\site-packages\numpy\lib\nanfunctions.py:1116: RuntimeWarning: All-NaN slice encountered
  overwrite_input=overwrite_input)

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Dependencies Required and optional dependencies
Projects
None yet
Development

No branches or pull requests

3 participants