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

timedelta64[ns]: max() and min() return numpy.int64 #2989

Closed
michaelaye opened this issue Mar 7, 2013 · 6 comments

Comments

@michaelaye
Copy link
Contributor

commented Mar 7, 2013

I guess that max() and min() are not implementing yet fully:

In [28]: diff.head()
Out[28]:
0               NaT
1   00:00:00.128001
2   00:00:00.127999
3   00:00:00.128001
4   00:00:00.127999
Dtype: timedelta64[ns]

In [29]: diff.max()
Out[29]: 1934745001000

In [30]: diff.max().dtype
Out[30]: dtype('int64')

In [31]: diff[0].dtype
Out[31]: dtype('timedelta64[ns]')

In [32]: diff.min().dtype
Out[32]: dtype('int64')
@jreback

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2013

timedeltas IS an int under the hood
but I'll take a look at some point

@jreback

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2013

#2990 should close this, merging soon

jreback added a commit to jreback/pandas that referenced this issue Mar 7, 2013
ENH: support min/max on timedelta64[ns] Series GH pandas-dev#2989
DOC: timedelta docs updates for min/max

TST: python3 issues
@jreback

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2013

this was merged into master....pls check out and let me know (also slight update on the docs, will be avail after 5pm est today I think...on the dev link)

@michaelaye

This comment has been minimized.

Copy link
Contributor Author

commented Mar 7, 2013

Works good, thanks a lot!

@michaelaye michaelaye closed this Mar 7, 2013

@michaelaye

This comment has been minimized.

Copy link
Contributor Author

commented Mar 7, 2013

oh, I noticed once thing odd, unrelated to this:

>>> diff.head()
0               NaT
1   00:00:00.127999
2   00:00:00.128000
3   00:00:00.128001
4   00:00:00.128000
dtype: timedelta64[ns]
>>> diff[0]
106751 days, 23:47:16.854775

but as usual, that's only a display issue, I guess?

@jreback

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2013

see below

the 'NaT' is really a np.datetime64, with really large negative value, its not a 'type'
like the 'NaT' in a datetime64[ns] series (its the same integer value tought)

datetime64[ns] series hold Timestamp types
there isn't an equivalent timedelta64 type (well there is, but its the numpy type np.datetime64)
and it doesn't know any about NaT

but I think numpy 1.7 fixes this (common usage is 1.6.2)

That's why I always wrap a series around the timedelta64s (even as a return value from max, which
really should be a scalar)

In [9]: td = pd.Series(pd.date_range('20130102',periods=6))

In [10]: td = td-td.shift()

In [11]: td
Out[11]: 
0                NaT
1   1 days, 00:00:00
2   1 days, 00:00:00
3   1 days, 00:00:00
4   1 days, 00:00:00
5   1 days, 00:00:00
dtype: timedelta64[ns]

In [12]: td[0]
Out[12]: 106751 days, 23:47:16.854775

In [13]: type(td[0])
Out[13]: numpy.timedelta64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.