Skip to content

Interpolating with method='time' incorrect for resolution higher than daily #1698

@kdebrab

Description

@kdebrab

The following code (pandas 0.8.0b2):

import pandas as pd
index = pd.date_range('1/1/2012', periods=4, freq='12D')
ts = pd.Series([0, 12, 24, 36], index)
new_index = index.append(index + pd.DateOffset(days=1)).order()
ts.reindex(new_index).interpolate(method='time')

correctly returns:
2012-01-01 0
2012-01-02 1
2012-01-13 12
2012-01-14 13
2012-01-25 24
2012-01-26 25
2012-02-06 36
2012-02-07 36

But when exchanging days for hours:

index = pd.date_range('1/1/2012', periods=4, freq='12H')
ts = pd.Series([0, 12, 24, 36], index)
new_index = index.append(index + pd.DateOffset(hours=1)).order()
ts.reindex(new_index).interpolate(method='time')

the result is not correct:
2011-01-01 00:00:00 0
2011-01-01 01:00:00 12
2011-01-01 12:00:00 12
2011-01-01 13:00:00 12
2011-01-02 00:00:00 24
2011-01-02 01:00:00 36
2011-01-02 12:00:00 36
2011-01-02 13:00:00 36

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions