TimedeltaIndex raises error when slicing from '0s' #10583

Closed
JonasAbernot opened this Issue Jul 15, 2015 · 5 comments

Comments

Projects
None yet
3 participants
Contributor

JonasAbernot commented Jul 15, 2015

import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.normal(size=(10,4)))
df.index = pd.timedelta_range(start='0s', periods=10, freq='s')

print(df.loc['0s':,:])

raises a ValueError: invalid resolution, while print(df.loc['5s':,:]) works.

Workaround : print(df.loc[pd.Timedelta('0s'):,:])

INSTALLED VERSIONS
------------------
commit: 6246cc1bb5149863de09b470530b69f7e22cad87
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-57-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: fr_FR.UTF-8

pandas: 0.16.2-138-g6246cc1
nose: 1.3.1
Cython: 0.20.1post0
numpy: 1.8.2
scipy: 0.13.3
statsmodels: None
IPython: 1.2.1
sphinx: 1.2.2
patsy: None
dateutil: 2.4.1
pytz: 2013b
bottleneck: None
tables: 3.1.1
numexpr: 2.2.2
matplotlib: 1.3.1
openpyxl: None
xlrd: None
xlwt: 0.7.5
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999
httplib2: 0.8
apiclient: None
sqlalchemy: 0.9.8
pymysql: None
psycopg2: None
Contributor

jreback commented Jul 15, 2015

https://github.com/pydata/pandas/blob/master/pandas/tslib.pyx#L2213

should be

else:
   return "D"

I guess the raise doesn't make sense.

@jreback jreback modified the milestone: Next Major Release, 0.17.0 Jul 15, 2015

@jreback jreback modified the milestone: Next Major Release, 0.17.0 Aug 20, 2015

Contributor

terrytangyuan commented Aug 31, 2015

@jreback no one is working on this, right? I'll submit a PR soon.

Contributor

jreback commented Aug 31, 2015

nope

Contributor

terrytangyuan commented Aug 31, 2015

Where should I put the test for this? @jreback Thanks.

Contributor

jreback commented Sep 1, 2015

test_timedeltas.py

@jreback jreback modified the milestone: 0.17.0, Next Major Release Sep 1, 2015

jreback closed this in #10960 Sep 1, 2015

@jreback jreback added a commit that referenced this issue Sep 1, 2015

@jreback jreback Merge pull request #10960 from terrytangyuan/PR2update
BUG: Fixed bug that Timedelta raises error when slicing from 0s (issue #10583)
9bdae60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment