Index.unique() should always return an Index object of the same type · Issue #13395 · pandas-dev/pandas (original) (raw)
This should also be noted in the docstring for the method.
Currently, it sometimes returns numpy arrays:
>>> pd.DatetimeIndex(['2000-01-01', '2000-01-02']).unique()
DatetimeIndex(['2000-01-01', '2000-01-02'], dtype='datetime64[ns]', freq=None)
>>> pd.Index([0, 1, 2]).unique()
array([0, 1, 2])
Most of the work here is probably writing comprehensive tests to check each index type.
xref: https://github.com/pydata/pandas/pull/13361/files/17209f92330c5e949934aec9dea039b35faf6e40#r66179418