Skip to content

BUG: Index name is not preserved during some conversions #10875

Closed
@soupault

Description

@soupault

The issue is existing name of Index is dropped during conversion to either TimedeltaIndex or DatetimeIndex.

In [42]: vec = ['01:02:03', '01:02:04']
In [43]: i = pd.Index(vec, name='label')
In [44]: i
Out[44]: Index(['01:02:03', '01:02:04'], dtype='object', name='label')

In [45]: pd.to_datetime(i)
Out[45]: DatetimeIndex(['2015-08-21 01:02:03', '2015-08-21 01:02:04'], dtype='datetime64[ns]', freq=None, tz=None)

In [46]: pd.to_timedelta(i)
Out[46]: TimedeltaIndex(['01:02:03', '01:02:04'], dtype='timedelta64[ns]', freq=None)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions