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
polyfit() fails on vectors with NaN #6037
Comments
This issue is similar to scipy/scipy#4060 -- in both cases pandas users want to use NaN to mean 'missing' in numpy/scipy interpolation or fitting, and in both cases a short term solution would be for the user to use weighted interpolation or fitting with zeros at the NaN locations. Unlike pandas, numpy and scipy do not generally interpret NaN as missing data. The longer-term solution would be to improve support for missing data across the scipy stack. |
I see. Thank you for the detailed answer! |
Now that I look at this more closely the NaNs are always together in (x, y) pairs, whereas the scipy issue linked above would be like just missing y values. In this case where both x and y are missing, I think it would be better to completely remove these pairs before the analysis rather than playing with weights. By the way, I had the idea that pandas was adding functions around these numpy/scipy functions to work automatically with NaN as missing data, but I've not been following pandas development closely. I'd expect something like |
I have two Pandas DataFrames:
Then I sort these series by increasing order of df_a : [0, 2, 1, 3, 4, 5, 13, 6, 7, 8, 9, 10, 11, 12].
Apply polynomial fitting (tried for several degrees):
And getting an error:
The warning is OK, but I still expect function to fit the polynomial. You can check that all the points are located near the imaginary line.
The problem is NaN handling, I suppose.
Also, I'm not sure what does the "Intel MKL" error mean.
SW versions:
python (3.4.2)
numpy (0.15.1)
cython (0.21.2)
pandas (0.15.2)
All libraries are taken from http://www.lfd.uci.edu/~gohlke/pythonlibs/ .
Platform: Windows 7 x64.
The text was updated successfully, but these errors were encountered: