Skip to content

Conversation

yui-knk
Copy link
Contributor

@yui-knk yui-knk commented Jul 17, 2016

pd.NaT, None, float('nan') and np.nan are
converted NaT in TestTimedeltas.
So we should convert keys if keys are these value.

Fix #13603

@@ -697,6 +697,10 @@ def get_loc(self, key, method=None, tolerance=None):
-------
loc : int
"""

if tslib.checknull_with_nat(key):
Copy link
Contributor

Choose a reason for hiding this comment

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

just use pd.isnull

@codecov-io
Copy link

codecov-io commented Jul 17, 2016

Current coverage is 84.38%

Merging #13687 into master will increase coverage by <.01%

@@             master     #13687   diff @@
==========================================
  Files           142        142          
  Lines         51223      51225     +2   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43224      43226     +2   
  Misses         7999       7999          
  Partials          0          0          

Powered by Codecov. Last updated by 6b9cd15...0960395

td = to_timedelta([pd.NaT])
for v in [pd.NaT, None, float('nan'), np.nan]:
self.assertTrue((v in td))

def test_construction(self):
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added!

@sinhrks
Copy link
Member

sinhrks commented Jul 17, 2016

I think related issues should be fixed by changing pd.Timedelta to return pd.NaT for these nat-likes (also _is_convertible_to_td should include nat-likes).

# OK
pd.Timestamp(np.nan)
# NaT
pd.Period(np.nan)
# NaT
pd.Timedelta(np.nan)
# NaT

# NG, Timedelta should return pd.NaT
pd.Timestamp(None)
# NaT
pd.Period(None)
# NaT
pd.Timedelta(None)
# ValueError: cannot construct a Timedelta without a value/unit or descriptive keywords (days,seconds....)

@sinhrks sinhrks added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Timedelta Timedelta data type labels Jul 17, 2016
@sinhrks sinhrks added this to the 0.19.0 milestone Jul 17, 2016
@sinhrks sinhrks added the Bug label Jul 17, 2016
@yui-knk
Copy link
Contributor Author

yui-knk commented Jul 18, 2016

I will challenge pd.Timedelta issue on another PR :)

@jreback
Copy link
Contributor

jreback commented Jul 18, 2016

ok, pls add a whatsnew entry, otherwise lgtm.

@yui-knk
Copy link
Contributor Author

yui-knk commented Jul 18, 2016

Updated a whatsnew entry!

pd.NaT, None, float('nan') and np.nan are
converted NaT in TestTimedeltas.
So we should convert keys if keys are these value.

Fix pandas-dev#13603
@jreback jreback closed this in 9f635cd Jul 19, 2016
@jreback
Copy link
Contributor

jreback commented Jul 19, 2016

thanks!

@yui-knk
Copy link
Contributor Author

yui-knk commented Jul 19, 2016

😄

@yui-knk yui-knk deleted the fix_13603 branch July 19, 2016 01:16
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.

Checking for any NaT-like objects in a TimedeltaIndex always returns True
4 participants