Skip to content

BUG: Unable to parse monthly-string in datetime.pxd #7289

Closed
@sinhrks

Description

@sinhrks

Travis build looks fail with following error.

  File "/home/travis/virtualenv/python2.6.9/lib/python2.6/site-packages/pandas/tseries/tests/test_period.py", line 1976, in test_range_slice_outofbounds
...
 File "datetime.pxd", line 137, in datetime._string_to_dts (pandas/tslib.c:52202)
ValueError: Unable to parse 2013/06

The failure is caused by test in DatetimeIndex, strangely PeriodIndex has no problem.

I don't know where datetime.pxd is derived from, but one assumption is the _string_to_dts uses todays date (31) in parsing process.

import pandas as pd

didx = pd.DatetimeIndex(start='2013/10/01', freq='D', periods=10)
pidx = pd.PeriodIndex(start='2013/10/01', freq='D', periods=10)

for idx in [didx, pidx]:
    df = pd.DataFrame(dict(units=[100 + i for i in range(10)]), index=idx)
    for key in ['2013/{0}'.format(i) for i in range(1, 13)]:
        try:
            df[key:'2013/03']
        except ValueError, e:
            print(type(idx), key, e)

# will prints
(<class 'pandas.tseries.index.DatetimeIndex'>, '2013/2', ValueError('Unable to parse 2013/2',))
(<class 'pandas.tseries.index.DatetimeIndex'>, '2013/4', ValueError('Unable to parse 2013/4',))
(<class 'pandas.tseries.index.DatetimeIndex'>, '2013/6', ValueError('Unable to parse 2013/6',))
(<class 'pandas.tseries.index.DatetimeIndex'>, '2013/9', ValueError('Unable to parse 2013/9',))
(<class 'pandas.tseries.index.DatetimeIndex'>, '2013/11', ValueError('Unable to parse 2013/11',))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions