Skip to content

Bug: resample options with TimedeltaIndex not working #15167

Closed
@perellonieto

Description

@perellonieto

Code Sample, a copy-pastable example if possible

import pandas as pd

index = pd.timedelta_range('0', periods=4, freq='s')
series = pd.Series(range(4), index=index)
print series

print series.resample('2s', label='left').sum()

print series.resample('2s', label='right').sum()

print series.resample('2s', label='right', closed='right').sum()

The output

00:00:00    0
00:00:01    1
00:00:02    2
00:00:03    3
Freq: S, dtype: int64
00:00:00    1
00:00:02    5
Freq: 2S, dtype: int64
00:00:00    1
00:00:02    5
Freq: 2S, dtype: int64
00:00:00    1
00:00:02    5
Freq: 2S, dtype: int64

Problem description

When calling the function resample with a DatetimeIndex works as expected. However, if called with a TimedeltaIndex the options label and closed does not work.

Expected Output

00:00:00    0
00:00:01    1
00:00:02    2
00:00:03    3
Freq: S, dtype: int64
00:00:00    1
00:00:02    5
Freq: 2S, dtype: int64
00:00:02    1
00:00:04    5
Freq: 2S, dtype: int64
00:00:00    0
00:00:02    3
00:00:04    3
Freq: 2S, dtype: int64

Output of pd.show_versions()

# Paste the output here pd.show_versions() here

INSTALLED VERSIONS

commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 3.19.0-74-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: None.None

pandas: 0.19.2
nose: 1.3.1
pip: 9.0.1
setuptools: 28.8.0
Cython: 0.24.1
numpy: 1.12.0
scipy: 0.18.1
statsmodels: 0.5.0
xarray: None
IPython: 4.1.2
sphinx: 1.4.6
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: None
tables: 3.1.1
numexpr: 2.2.2
matplotlib: 1.5.3
openpyxl: 1.7.0
xlrd: 0.9.2
xlwt: 0.7.5
xlsxwriter: None
lxml: None
bs4: 4.2.1
html5lib: 0.999
httplib2: 0.8
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: 2.4.5 (dt dec mx pq3 ext)
jinja2: 2.8
boto: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resampleresample methodTimedeltaTimedelta data type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions