Skip to content

partial slicing FAILS with a datetimeindex  #13539

Closed
@randomgambit

Description

@randomgambit

Hi,

I have a simple dataframe with a multiindex.

stats.index.names
Out[67]: FrozenList([u'day', u'category'])

day is a time variable, category is a string.

stats.index.inferred_type
Out[69]: 'mixed'

stats.index.dtype_str
Out[68]: 'object'

if I type

idx=pd.IndexSlice
stats.loc[idx['2015-01-01',:],:]

I get the correct slice at '2015-01-01', that is all the observations for all the categories on that day.

If I type

idx=pd.IndexSlice
stats.loc[idx['2015',:],:] 

I get back (almost) all my observations, even for years other than 2015.

What can be the problem here? I cannot paste the data unfortunately but I am happy to help in any way.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatetimeDatetime data dtypeDuplicate ReportDuplicate issue or pull requestIndexingRelated to indexing on series/frames, not to indexes themselvesMultiIndex

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions