Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: DateTimeIndex slicing removes name label #4226

Closed
diezguerra opened this issue Jul 12, 2013 · 8 comments

Comments

Projects
None yet
3 participants
@diezguerra
Copy link

commented Jul 12, 2013

Shouldn't it carry all possible properties instead?

Steps to reproduce:

import pandas as pd


st = pd.Timestamp('2013-07-01 00:00:00', tz='America/Los_Angeles')
et = pd.Timestamp('2013-07-02 00:00:00', tz='America/Los_Angeles')

dr = pd.date_range(st, et, freq='H', name='timebucket')
assert dr.name == 'timebucket'
dr = dr[1:]
assert dr.name == None
@jreback

This comment has been minimized.

Copy link
Contributor

commented Jul 13, 2013

related to #4039 I think, cc @jtratner

@cpcloud

This comment has been minimized.

Copy link
Member

commented Jul 13, 2013

hm weird. looks like the overridden __getitem__ is not being called...

@cpcloud

This comment has been minimized.

Copy link
Member

commented Jul 13, 2013

In [9]: paste
st = pd.Timestamp('2013-07-01 00:00:00', tz='America/Los_Angeles')
et = pd.Timestamp('2013-07-02 00:00:00', tz='America/Los_Angeles')

dr = pd.date_range(st, et, freq='H', name='timebucket')

## -- End pasted text --

In [10]: dr[1:]
Out[10]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2013-07-01 01:00:00, ..., 2013-07-02 00:00:00]
Length: 24, Freq: H, Timezone: America/Los_Angeles

In [11]: dr[1:].name

In [12]: dr.__getitem__(slice(1, None)).name
Out[12]: 'timebucket'
@jreback

This comment has been minimized.

Copy link
Contributor

commented Jul 13, 2013

I think is a short cut I put in, something like getitem_slice in tseries/index

@cpcloud

This comment has been minimized.

Copy link
Member

commented Jul 13, 2013

same issue for Index(['a','b']) as well

@cpcloud

This comment has been minimized.

@cpcloud

This comment has been minimized.

Copy link
Member

commented Jul 13, 2013

passes when i define that in terms of __getitem__

@cpcloud

This comment has been minimized.

Copy link
Member

commented Jul 13, 2013

pr coming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.