Skip to content

API: DatetimeIndex / TimedeltaIndex 2d slicing should result in Index #10774

Closed
@sinhrks

Description

@sinhrks

Following slices basically result in the same Index.

import pandas as pd
pd.Index([1, 2, 3])[:, None]
# Int64Index([[1], [2], [3]], dtype='int64')
pd.MultiIndex.from_tuples([('a', 1), ('b', 2)])[:, None]
# MultiIndex(levels=[[u'a', u'b'], [1, 2]],
#            labels=[[[0], [1]], [[0], [1]]])

pd.period_range('2011-01-01', freq='M', periods=3)[:, None]
# PeriodIndex(['2011-01', '2011-02', '2011-03'], dtype='int64', freq='M')

But DatetimeIndex and TimedeltaIndex doesn't because of following line.

pd.date_range('2011-01-01', freq='M', periods=3)[:, None]
# array([['2011-01-31T09:00:00.000000000+0900'],
#        ['2011-02-28T09:00:00.000000000+0900'],
#        ['2011-03-31T09:00:00.000000000+0900']], dtype='datetime64[ns]')
pd.timedelta_range('1 days', freq='D', periods=3)[:, None]
# array([[ 86400000000000],
#        [172800000000000],
#        [259200000000000]], dtype='timedelta64[ns]')

I understand these must be Index also, or any reason for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementError ReportingIncorrect or improved errors from pandasIndexRelated to the Index class or subclassesIndexingRelated to indexing on series/frames, not to indexes themselvesgood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions