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 · Fixed by #4233
Closed

API: DateTimeIndex slicing removes name label #4226

diezguerra opened this issue Jul 12, 2013 · 8 comments · Fixed by #4233
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@diezguerra
Copy link

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
Copy link
Contributor

jreback commented Jul 13, 2013

related to #4039 I think, cc @jtratner

@cpcloud
Copy link
Member

cpcloud commented Jul 13, 2013

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

@cpcloud
Copy link
Member

cpcloud 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
Copy link
Contributor

jreback commented Jul 13, 2013

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

@cpcloud
Copy link
Member

cpcloud commented Jul 13, 2013

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

@cpcloud
Copy link
Member

cpcloud commented Jul 13, 2013

@cpcloud
Copy link
Member

cpcloud commented Jul 13, 2013

passes when i define that in terms of __getitem__

@cpcloud
Copy link
Member

cpcloud commented Jul 13, 2013

pr coming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants