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

ERR: Maximum recursion depth exceeded in comparision when comparing a TimeDelta to numpy object array of TimeDelta #11835

Closed
WarrenWeckesser opened this issue Dec 13, 2015 · 1 comment · Fixed by #11957
Labels
Bug Timedelta Timedelta data type
Milestone

Comments

@WarrenWeckesser
Copy link

See http://stackoverflow.com/questions/34251068/runtimeerror-from-scipy-stats-mode-on-array-of-timedelta-maximum-recursion-dept

Python 3.5.1, pandas 0.17.1, numpy 0.10.1:

Python 3.5.1 |Continuum Analytics, Inc.| (default, Dec  7 2015, 11:24:55) 
Type "copyright", "credits" or "license" for more information.

IPython 4.0.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import numpy as np

In [2]: np.__version__
Out[2]: '1.10.1'

In [3]: import pandas as pd

In [4]: pd.__version__
Out[4]: '0.17.1'

Create a numpy array of TimeDelta objects, and do a comparison of the array to a TimeDelta instance:

In [5]: from pandas import Timedelta

In [6]: periods = [Timedelta('0 days 01:00:00'), Timedelta('0 days 01:00:00')]

In [7]: p = np.array(periods)

In [8]: periods[0] > p
---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
<ipython-input-8-1c05a376ecc2> in <module>()
----> 1 periods[0] > p

pandas/tslib.pyx in pandas.tslib._Timedelta.__richcmp__ (pandas/tslib.c:38155)()

<SNIP>

pandas/tslib.pyx in pandas.tslib._Timedelta.__richcmp__ (pandas/tslib.c:38155)()

pandas/tslib.pyx in pandas.tslib._Timedelta.__richcmp__ (pandas/tslib.c:38155)()

RecursionError: maximum recursion depth exceeded in comparison

In [9]: 
@jreback
Copy link
Contributor

jreback commented Dec 13, 2015

ok. you should use a TimedeltaIndex; a numpy array of Timedeltas is not very useful.

In any event looks like a bug in the comparison ops. pull -requests welcome.

@jreback jreback added this to the Next Major Release milestone Dec 13, 2015
@jreback jreback changed the title Maximum recursion depth exceeded in comparision when comparing a TimeDelta to numpy object array of TimeDeltas ERR: Maximum recursion depth exceeded in comparision when comparing a TimeDelta to numpy object array of TimeDelta Dec 13, 2015
@jreback jreback modified the milestones: 0.18.0, Next Major Release Jan 5, 2016
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
Development

Successfully merging a pull request may close this issue.

2 participants