Skip to content

API: .dt.components attribute on timedelta series does not preserve the index #9247

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

Closed
jorisvandenbossche opened this issue Jan 14, 2015 · 1 comment · Fixed by #9248
Closed
Labels
Bug Timedelta Timedelta data type
Milestone

Comments

@jorisvandenbossche
Copy link
Member

In [70]: tds = pd.Series(pd.timedelta_range('1 days', periods=5, freq='2 h'), index=list('ABCDE'))

In [71]: tds
Out[71]:
A   1 days 00:00:00
B   1 days 02:00:00
C   1 days 04:00:00
D   1 days 06:00:00
E   1 days 08:00:00
dtype: timedelta64[ns]

In [72]: tds.dt.hours
Out[72]:
A    0
B    2
C    4
D    6
E    8
dtype: int64

In [73]: tds.dt.components.hours
Out[73]:
0    0
1    2
2    4
3    6
4    8
Name: hours, dtype: int64

So the direct attributes via .dt like .dt.hours above does preserve the index, but the components not.

@jreback I don't know if this was done on purpose or is an oversight, I can't remember, and I looked briefly to the long discussion in #8184, but didn't find something directly.

@jreback
Copy link
Contributor

jreback commented Jan 14, 2015

this is a bug - it should be the same index

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Timedelta Timedelta data type
Projects
None yet
2 participants