Skip to content

fix issue #8000 #8010

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
wants to merge 2 commits into from
Closed

fix issue #8000 #8010

wants to merge 2 commits into from

Conversation

grahamjeffries
Copy link
Contributor

This pull request is in response to issue #8000.

Changes to core/common.py add np.nan as the default value for missing values to the left and right non-missing values during interpolation. This prevents DataFrame.interpolate() from extrapolating the last non-missing value over all trailing missing values (the default).

Changes to tests/test_common.py add test coverage to the above change. A passing test is where an interpolated series with a trailing missing value maintains that trailing missing value after interpolation.

This commit changes `np.interp()` arguments to include the default values of the left and right parameters as np.nan. In effect, when pandas interpolates a Series with trailing missing data, missing data values are preserved rather than being overwritten with the default value (last non-missing value).
Added a test that confirms that linear interpolation of a Series does not extrapolate over missing data that trails the last known value.
def test_interpolate_linear():
a = Series([np.nan, 1, np.nan, 3, np.nan]))
b = a.interpolate()
assert(b[4] == np.nan)
Copy link
Contributor

Choose a reason for hiding this comment

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

construct an expected series and use assert_series equal

move this test to test_generic (u will see a whole bunch of other interpolation tests)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resubmitted as PR #8013 with suggested edits

@jreback
Copy link
Contributor

jreback commented Aug 13, 2014

FYI, in general to simply rebase the PR rather than submit a new one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants