Skip to content
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

correction to get time interpolation correct #39886

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
Tick,
)

from pandas.core.reshape.concat import concat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your imports are in the wrong order and causing failed checks.

run > isort pandas


_shared_docs_kwargs: Dict[str, str] = {}


Expand Down Expand Up @@ -859,6 +861,11 @@ def interpolate(
Interpolate values according to different methods.
"""
result = self._upsample("asfreq")
if isinstance(result.index, DatetimeIndex):
obj = self._selected_obj
tmp = concat([obj, result]).sort_index().interpolate(method='time')
tmp = tmp[result.index]
result[...] = tmp[~tmp.index.duplicated(keep='first')]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are not following standard code guideines, e.g. use " instead of '.

run > black pandas this will automatically fix these issues for you.

return result.interpolate(
method=method,
axis=axis,
Expand Down