Skip to content

BUG: Timedelta.__floordiv__ - need historical context #18846

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
jbrockmendel opened this issue Dec 19, 2017 · 2 comments · Fixed by #18831 or #18961
Closed

BUG: Timedelta.__floordiv__ - need historical context #18846

jbrockmendel opened this issue Dec 19, 2017 · 2 comments · Fixed by #18831 or #18961
Labels
Bug Timedelta Timedelta data type
Milestone

Comments

@jbrockmendel
Copy link
Member

>>> pd.Timedelta(days=3, hours=4) // np.datetime64('NaT')
-1

Timedelta.__floordiv__ and __rfloordiv__ begin with:

        if hasattr(other, 'dtype'):
            # work with i8
            other = other.astype('m8[ns]').astype('i8')

I think this is a historical artifact from early numpy versions, because in core.ops there is a comment:

            # time delta division -> unit less
            # integer gets converted to timedelta in np < 1.6
            if ((self.is_timedelta_lhs and self.is_timedelta_rhs) and
                    not self.is_integer_rhs and not self.is_integer_lhs and
                    self.name in ('__div__', '__truediv__')):

Before I try to fix Timedelta.__floordiv__ can someone knowledgeable weight in on why all dtypes are being converted to i8?

@jreback
Copy link
Contributor

jreback commented Dec 20, 2017

yes I think this is ok (to fix), maybe some prior version . numpy issues we were working around

@jreback jreback modified the milestones: Next Major Release, 0.22.0 Dec 20, 2017
@jbrockmendel
Copy link
Member Author

This issue goes with #18961, not 18831.

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
2 participants