-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: interpolate method with 'index' and 'slinear' methods give inconsistent results when there are duplicates in x-axis #42585
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
Thanks for the report! For the expected output, can you provided the expected values from your examples. |
Hi, in all examples above, the expected interpolated value is "-50":
|
Hi, Please let me know if you need something else, Thanks! |
Ran into this separately today with |
If I'm correct about the root cause, it would've been introduced by #29943 |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Output:
Problem description
I am trying to use pandas to interpolate "curves" that can have "steps" (eg. 2 consecutive points with same x-coordinate, but different y-coordinate, or the other way around). There can be an arbitrary number of NaN values between 2 points.
I think this is quite a common use case, and I think i would be cool to have pandas able to perform this kind of "point-to-point" interpolation.
I have been using either "index" or "slinear" methods to do so. While it seems to work in most cases, there seem to be inconsistencies around:
Expected Output
I would like all NA values to be linearly interpolated locally, based on the 'previous' and 'next' points (Side note, for extrapolation, 'nearest'-like approach seems to be the most sensible outcome).
Output of
pd.show_versions()
commit : f00ed8f
python : 3.7.8.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder : little
LC_ALL : None
LANG : fr_FR.UTF-8
LOCALE : None.None
pandas : 1.3.0
numpy : 1.20.3
pytz : 2021.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 47.1.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.7.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: