Skip to content

Index._maybe_cast_slice_bound switched meaning of left/right #14354

Closed
@mrocklin

Description

@mrocklin

'left' and 'right' changed meaning in DatetimeIndex._maybe_cast_slice_bound. Was this intentional?

Pandas 0.18

In [1]: import pandas as pd

In [2]: index = pd.DatetimeIndex(freq='1H', periods=0, end='2015')

In [3]: index._maybe_cast_slice_bound('2015-01-02', 'right', 'loc')
Out[3]: Timestamp('2015-01-02 23:59:59.999999999')

In [4]: index._maybe_cast_slice_bound('2015-01-02', 'left', 'loc')
Out[4]: Timestamp('2015-01-02 00:00:00')

Pandas 0.19

In [1]: import pandas as pd

In [2]: index = pd.DatetimeIndex(freq='1H', periods=0, end='2015')

In [3]: index._maybe_cast_slice_bound('2015-01-02', 'right', 'loc')
Out[3]: Timestamp('2015-01-02 00:00:00')

In [4]: index._maybe_cast_slice_bound('2015-01-02', 'left', 'loc')
Out[4]: Timestamp('2015-01-02 23:59:59.999999999')

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions