Skip to content

BUG: Unexpected behauvior interpolate limit with time and direction "both" #52322

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
3 tasks done
bartvaneswhiffle opened this issue Mar 31, 2023 · 4 comments
Closed
3 tasks done
Labels
Closing Candidate May be closeable, needs more eyeballs Datetime Datetime data dtype

Comments

@bartvaneswhiffle
Copy link

bartvaneswhiffle commented Mar 31, 2023

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

from io import StringIO

import pandas as pd


csv = """time,a,b
2021-01-01 00:00:00,0,7
2021-01-01 01:00:00,4,11
2021-01-01 01:30:00,6,12"""

df = pd.read_csv(StringIO(csv), sep=",", parse_dates=["time"])
df = df.set_index("time")
print(df)
df = df.resample("15T").interpolate(
                method="time", limit=1, limit_direction="both"
            )

print(df)

Issue Description

This does interpolate the gap bigger than 1 nan?

Expected Behavior

                   a     b

time
2021-01-01 00:00:00 0.0 7.0
2021-01-01 00:15:00 NaN NaN
2021-01-01 00:30:00 NaN NaN
2021-01-01 00:45:00 NaN NaN
2021-01-01 01:00:00 4.0 11.0
2021-01-01 01:15:00 5.0 11.5
2021-01-01 01:30:00 6.0 12.0

Installed Versions

INSTALLED VERSIONS

commit : 2e218d1
python : 3.10.10.final.0
python-bits : 64
OS : Linux
OS-release : 5.19.0-38-generic
Version : #39~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 17 21:16:15 UTC 2
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.5.3
numpy : 1.24.2
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 65.6.3
pip : 23.0.1
Cython : None
pytest : 7.2.1
hypothesis : None
sphinx : 6.1.3
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.7.0
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.1
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.1
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : 2022.11.0
xlrd : None
xlwt : None
zstandard : None
tzdata : None

@bartvaneswhiffle bartvaneswhiffle added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 31, 2023
@MarcoGorelli
Copy link
Member

thanks for the report, could you put a descriptive title pleasE?

@bartvaneswhiffle bartvaneswhiffle changed the title BUG: BUG: Unexpected behauvior interpolate limit with time and direction "both" Mar 31, 2023
@adityaraute
Copy link

What's the plan here??

@MarcoGorelli
Copy link
Member

Not sure I follow the issue - isn't this expected? You've said that limit=1, and direction='both', so one nan was interpolated in both directions

I may be misunderstanding though, so putting 'closing candidate' for now

@MarcoGorelli MarcoGorelli added Datetime Datetime data dtype Closing Candidate May be closeable, needs more eyeballs and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 4, 2023
@bartvaneswhiffle
Copy link
Author

Allright, it is indeed not a bug. I now understand how this is implemented this way (not sure when this is usefull), the documentation could be more clear.. I would expect having a limit in a interpolation to skip gaps bigger than the limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closing Candidate May be closeable, needs more eyeballs Datetime Datetime data dtype
Projects
None yet
Development

No branches or pull requests

3 participants