-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
pandas give a warning when working with np.NaN values #9950
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
Comments
this was fixed by #9764 and will be in 0.16.1. |
I'm experiencing the exact same problem, but I have 0.16.1. Did the fix not make it in, or am I doing something wrong? Thanks in advance for your help.
|
@domenb you should check whether you have a 'partially' updated installation. There was an older bug with conda that would if you were running python processes not update fully. Do this.
|
I did the following:
I then repeated the above test, and the behavior was identical. I have conda 3.11.0. I just deleted and reinstalled Anaconda last week. It is Anaconda-2.2.0-Windows-x86. I have numpy 1.9.2. I don't know if @domenb got this working, but please let me know if you think this is unrelated, or if I should create a separate issue. Thanks |
This is a user installation problem. I would guess that they have maybe
|
I am the one who have created #10256, and - just as jorisvandenbossche wrote above - I've also experienced the problem, while writing to the console. That is, I wrote it into a "normal" console (included in the Spyder IDE), not an IPython one as you did above. In the IPython Console (or Notebook) it also works just fine. Besides I am using neither conda nor miniconda, but the latest WinPython, that includes 0.16.1 "by default". >>> import numpy as np
>>> import pandas as pd
>>> pd.__version__
'0.16.1'
>>> pd.Series([np.nan,np.nan,np.nan],index=[1,2,3])
1 NaN
2 NaN
3 NaN
dtype: float64
R:\WinPython\python-3.4.3.amd64\lib\site-packages\pandas\core\format.py:2012: RuntimeWarning: invalid value encountered in greater
has_large_values = (abs_vals > 1e8).any()
R:\WinPython\python-3.4.3.amd64\lib\site-packages\pandas\core\format.py:2013: RuntimeWarning: invalid value encountered in less
has_small_values = ((abs_vals < 10 ** (-self.digits+1)) &
R:\WinPython\python-3.4.3.amd64\lib\site-packages\pandas\core\format.py:2014: RuntimeWarning: invalid value encountered in greater
(abs_vals > 0)).any()
>>> I have already included my environment parameters in the above mentioned #10256. |
Well, this is 2.7.9, numpy 1.9.2, pandas 0.16.1 on windows. And its python, not ipython.
|
Hi I am encountering the same issue. I have the latest versions of pandas and numpy. Details are below. h
/anaconda3/lib/python3.4/site-packages/pandas/core/format.py:2012: RuntimeWarning: invalid value encountered in greater
has_large_values = (abs_vals > 1e8).any()
/anaconda3/lib/python3.4/site-packages/pandas/core/format.py:2013: RuntimeWarning: invalid value encountered in less
has_small_values = ((abs_vals < 10 ** (-self.digits+1)) &
/anaconda3/lib/python3.4/site-packages/pandas/core/format.py:2014: RuntimeWarning: invalid value encountered in greater
(abs_vals > 0)).any()
Out[135]:
X0 X1 X2
DATE
2013-01-01 00:00:00+00:00 -0.220539 0.166106 NaN
2013-01-02 00:00:00+00:00 -0.229826 0.304425 -0.023634
pd.__version__
Out[136]: '0.16.1'
np.__version__
Out[137]: '1.9.2' |
I come across the same issue too. I did a fresh conda install (anaconda-3.2.3) on my linux machine and ran into issues when dataframes started containing nans Below are the pandas and numpy versions pd.version np.version This relates to formatting floats (which is what an np.nan is represented as). You can work around it by defining your own formatter function and setting it as an option. pd.set_option('display.float_format', lambda x:'%f'%x) |
|
@quantstud @jdmcbr @cousin333 Has this problem stayed fixed for you? I'm still having issues with this -- |
The issue as mentioned above under spyder (RuntimeWarning: with pandas.dataframes spyder-ide/spyder#2991) aslo occurs when using WinPython instead of conda. |
@dacoex have we concluded this is a spyder problem and not a pandas problem? |
@nickeubank It was not actually fixed, as it turned out. I looked through the issue @dacoex mentions, and that matches my experiences perfectly. After trying the |
K - @jreback , sounds like this is still an issue for many people. Could we re-open? |
@nickeubank I just tested, and only saw this issue in a python console within Spyder. It did not occur in a python console outside of Spyder. So I think it is appropriately closed here. |
again I suspect its a non-complete update for some folks. esp on windows, you have to make sure that nothing is touching the env when you updated things. This has been fixed in newer versions of conda, but if you are doing it some other way then you may have issues. |
(Spyder maintainer here). My findings are:
Conclusion: Please stop bothering @jreback and instead bother me in spyder-ide/spyder#2991 ;-) |
@jreback, is it ok for us to simply filter this warning? I still don't understand where it's coming from (we import Pandas in several places, but those imports don't seem to have an effect on suppressing the warning). |
@ccordoba12 yeah all of this code was changed for 0.18.0 (unreleated to this, much more to make it DRY & to make sure FloatIndexes were printing correctly). I relooked at this issue, its on 32-bit windows. See the warning (coming from numpy) below. I would say this is really a numpy bug. I'll create an issue. As far as filtering, sure I don't think it actually hurts anything, but I don't think you need to on 0.18.0.
|
xref numpy/numpy#7440 |
I get the same warning message on linux 64bits in Spyder 2.3.8 as soon as I type the last parenthesis of Python 3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Dec 7 2015, 11:16:01) I can't reproduce the warning message with the standard ipython console. |
@mhabets, as I said, this is going to be fixed in Spyder 2.3.9. |
@ccordoba12 the problem is seems not fixed in Spyder 2.3.9 |
I am getting this type warnings again now in 2025. This problem is raised again. Right now, I am facing on Kaggle:df1.head() /usr/local/lib/python3.10/dist-packages/pandas/io/formats/format.py:1458: RuntimeWarning: invalid value encountered in greater has_large_values = (abs_vals > 1e6).any() /usr/local/lib/python3.10/dist-packages/pandas/io/formats/format.py:1459: RuntimeWarning: invalid value encountered in less has_small_values = ((abs_vals < 10 ** (-self.digits)) & (abs_vals > 0)).any() /usr/local/lib/python3.10/dist-packages/pandas/io/formats/format.py:1459: RuntimeWarning: invalid value encountered in greater has_small_values = ((abs_vals < 10 ** (-self.digits)) & (abs_vals > 0)).any() /usr/local/lib/python3.10/dist-packages/pandas/io/formats/format.py:1458: RuntimeWarning: invalid value encountered in greater has_large_values = (abs_vals > 1e6).any() /usr/local/lib/python3.10/dist-packages/pandas/io/formats/format.py:1459: RuntimeWarning: invalid value encountered in less has_small_values = ((abs_vals < 10 ** (-self.digits)) & (abs_vals > 0)).any() /usr/local/lib/python3.10/dist-packages/pandas/io/formats/format.py:1459: RuntimeWarning: invalid value encountered in greater has_small_values = ((abs_vals < 10 ** (-self.digits)) & (abs_vals > 0)).any() How I can resolve this issue? |
When I create a pandas.Series or pandas.DataFrame having np.NaN values, I get the following warning.
Example:
I am using Anaconda-2.2.0-Windows-x86_64, with Python 2.7.9. and pandas 0.16.0.
I would ask you to advise.
The text was updated successfully, but these errors were encountered: