A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/7540 below:

PeriodIndex.unique returns ndarray · Issue #7540 · pandas-dev/pandas · GitHub

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4