Skip to content

BUG: allow .std() of timedelta types #8471

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
jreback opened this issue Oct 5, 2014 · 0 comments · Fixed by #8476
Closed

BUG: allow .std() of timedelta types #8471

jreback opened this issue Oct 5, 2014 · 0 comments · Fixed by #8476
Labels
Bug Numeric Operations Arithmetic, Comparison, and Logical operations Timedelta Timedelta data type
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Oct 5, 2014

This currently raises TypeError as its disabled in core/nanops.py, see here: d29d4c6

The issue is that .var() can generate a value that is too big for the timedeltas to hold propery, and std CALLS var.

solns:

  • reduce the value of the timedeltas going into var to make them work (and inflate on exit), e.g. divide by 1e9 or something. lose some small amount of precision.
  • allow std to return a valid value by passing a flag thru to var (and don't wrap the results). a bit hacky
In [7]: max_int = np.iinfo(np.int64).max

In [8]: max_int
Out[8]: 9223372036854775807

In [9]: pd.Timedelta(max_int)
Out[9]: Timedelta('106751 days 23:47:16.854775')

In [10]: big_float = 3e19

In [12]: pd.Timedelta(big_float)
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
OverflowError: Python int too large to convert to C long

In [13]: pd.Timedelta(np.sqrt(big_float))
Out[13]: Timedelta('0 days 00:00:05.477225')
@jreback jreback added Bug Good as first PR Numeric Operations Arithmetic, Comparison, and Logical operations Timedelta Timedelta data type labels Oct 5, 2014
@jreback jreback added this to the 0.15.1 milestone Oct 5, 2014
@jreback jreback changed the title BUG: allow .std() of timedelta types BUG: allow .std() of timedelta types Oct 5, 2014
@jreback jreback modified the milestones: 0.15.0, 0.15.1 Oct 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Numeric Operations Arithmetic, Comparison, and Logical operations Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant