Index._maybe_cast_slice_bound switched meaning of left/right · Issue #14354 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@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')