API: change datetimelike Index to raise IndexError instead ValueError by jorisvandenbossche · Pull Request #18386 · pandas-dev/pandas (original) (raw)

I noticed this in the plotting PR that DatetimeIndex et al behave a bit strange on an invalid index:

In [41]: pd.Index([1, 2, 3])['no_int']
...
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

In [42]: pd.DatetimeIndex([1, 2, 3])['no_int']
...
ValueError: