Skip to content

"can't compare datetime.date to str" in slicing/indexing (version 0.11.0) #3532

Closed
@vfilimonov

Description

@vfilimonov

Hello all

I don't know if this has been already fixed in developing 0.12, but just in case:

it seemed that indexing with datetime.date does not work properly.

E.g. the code

IDX=[datetime.strptime(yy,'%Y-%m-%d') for yy in ["2005-01-01","2006-01-01","2006-01-01","2007-01-01"]]
IDX
df = pd.DataFrame([1,2,3,4], index=IDX)
print type(df.index[0])
print df.ix['2005-01-01']
df[:'2006-01-02']

works correctly. And the code

IDX=[datetime.date(datetime.strptime(yy,'%Y-%m-%d')) for yy in ["2005-01-01","2006-01-01","2006-01-01","2007-01-01"]]
IDX
df = pd.DataFrame([1,2,3,4], index=IDX)
print type(df.index[0])
print df.ix['2005-01-01']
df[:'2006-01-02']

failed with the issue "TypeError: can't compare datetime.date to str"

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