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

ENH: support min/max on timedelta64[ns] Series #2990

Merged
merged 2 commits into from
Mar 7, 2013

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Mar 7, 2013

closes GH #2989

In [168]: df = DataFrame(dict(A = s - Timestamp('20120101')-timedelta(minutes=5,seconds=5),
   .....:                     B = s - Series(date_range('2012-1-2', periods=3, freq='D'))))
   .....:

In [169]: df
Out[169]: 
                 A                 B
0        -00:05:05 -1 days, 00:00:00
1         23:54:55 -1 days, 00:00:00
2 1 days, 23:54:55 -1 days, 00:00:00

In [170]: df.min()
Out[170]: 
A           -00:05:05
B   -1 days, 00:00:00
dtype: timedelta64[ns]

In [171]: df.min(axis=1)
Out[171]: 
0   -1 days, 00:00:00
1   -1 days, 00:00:00
2   -1 days, 00:00:00
dtype: timedelta64[ns]

In [172]: df.idxmin()
Out[172]: 
A    0
B    0
dtype: int64

In [173]: df.idxmax()
Out[173]: 
A    2
B    0
dtype: int64

min, max operations are support on series, these return a single element timedelta64[ns] Series 
(this avoids having to deal with numpy timedelta64 issues). idxmin, idxmax are supported as well.

In [306]: df.min().max()
Out[306]: 
0   -00:05:05
dtype: timedelta64[ns]

In [307]: df.min(axis=1).min()
Out[307]: 
0   -1 days, 00:00:00
dtype: timedelta64[ns]

In [308]: df.min().idxmax()
Out[308]: 'A'

In [309]: df.min(axis=1).idxmin()
Out[309]: 0

jreback added a commit that referenced this pull request Mar 7, 2013
ENH: support min/max on timedelta64[ns] Series
@jreback jreback merged commit 9429c03 into pandas-dev:master Mar 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant