-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
API DesignCompatpandas objects compatability with Numpy or Python functionspandas objects compatability with Numpy or Python functionsPeriodPeriod data typePeriod data type
Milestone
Description
Currently, Index.unique returns ndarray but DatetimeIndex.unique returns DatetimeIndex to preserve datetime information. I think PeriodIndex.unique should also return PeriodIndex (currently it returns ndarray).
I'd like to ask which is better to fix all Index.unique to return Index for consistency, or only fix PeriodIndex.
didx = pd.DatetimeIndex([datetime.datetime(2014, 1, 1), datetime.datetime(2014, 2, 1)])
didx.unique()
# <class 'pandas.tseries.index.DatetimeIndex'>
# [2014-01-01, 2014-02-01]
pidx = pd.PeriodIndex(['2014-01', '2014-02'], freq='M')
pidx.unique()
# [528 529]
type(pidx.unique())
# <type 'numpy.ndarray'>
Metadata
Metadata
Assignees
Labels
API DesignCompatpandas objects compatability with Numpy or Python functionspandas objects compatability with Numpy or Python functionsPeriodPeriod data typePeriod data type