A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/9247 below:

.dt.components attribute on timedelta series does not preserve the index · Issue #9247 · pandas-dev/pandas · GitHub

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.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4