Skip to content

BUG: None / Timedelta incorrectly returning NaT #32340

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

Merged
merged 2 commits into from
Mar 3, 2020

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

xref #31869, arguable whether or not this closes that.

@WillAyd
Copy link
Member

WillAyd commented Feb 29, 2020

Not against the design just curious as to what your thought is as to why this should raise instead of returning NaN? Perhaps because np.nan / pd.NaT is ambiguous?

@WillAyd WillAyd added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Timedelta Timedelta data type labels Feb 29, 2020
@jbrockmendel
Copy link
Member Author

why this should raise instead of returning NaN? Perhaps because np.nan / pd.NaT is ambiguous?

Think of it as if we had non-NA scalars of the same types/dtypes. e.g. 2.0 / Timedelta(days=1) is obviously gibberish. So treat np.nan / Timedelta(days=1) the same

# GH#31869 None gets cast to NaT
td = Timedelta(10, unit="d")

result = NaT / td
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe as a follown split out the these non-error casees and use nulls_fixture (as you then can test float('nan')

@jreback jreback added this to the 1.1 milestone Mar 3, 2020
@jreback jreback merged commit 4ba48f0 into pandas-dev:master Mar 3, 2020
@jreback
Copy link
Contributor

jreback commented Mar 3, 2020

thanks

@jbrockmendel jbrockmendel deleted the none_div_td branch November 20, 2021 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants