Skip to content

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Jul 9, 2016

Series and Index compares NaT == NaT as True if it has object dtype.

pd.Series([pd.NaT])
#0   NaT
# dtype: datetime64[ns]

# OK
pd.Series([pd.NaT]) == pd.NaT
#0    False
# dtype: bool

# NG in object dtype
pd.Series([pd.NaT], dtype=object) == pd.NaT
#0    True
# dtype: bool

# OK
pd.Index([pd.NaT]) == pd.NaT
array([False], dtype=bool)

# NG in object dtype
pd.Index([pd.NaT], dtype=object) == pd.NaT
# array([ True], dtype=bool)

@sinhrks sinhrks changed the title BUG: Series contains NaT with object dtype comparison incorrect BUG: Series/Index contains NaT with object dtype comparison incorrect Jul 9, 2016
@sinhrks sinhrks added Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate labels Jul 9, 2016
@sinhrks sinhrks added this to the 0.19.0 milestone Jul 9, 2016
@codecov-io
Copy link

codecov-io commented Jul 9, 2016

Current coverage is 84.33%

Merging #13592 into master will increase coverage by 0.01%

@@             master     #13592   diff @@
==========================================
  Files           138        138          
  Lines         51165      51100    -65   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits          43142      43097    -45   
+ Misses         8023       8003    -20   
  Partials          0          0          

Powered by Codecov. Last updated by 1edc1df...f95dae7

@jreback
Copy link
Contributor

jreback commented Jul 9, 2016

lgtm. Do we have an associated issue? I do recall this somewhere.

@sinhrks
Copy link
Member Author

sinhrks commented Jul 10, 2016

Maybe #9005, though it looks to be fixed on current master (but added tests for native/object dtypes).

@sinhrks
Copy link
Member Author

sinhrks commented Jul 10, 2016

Ah, found #9005 is not fixed yet. If NaT is on rhs (on current master):

pd.Series([pd.Timestamp('2011-01-01')]) > pd.Series([pd.NaT])
# 0    True
# dtype: bool

Already included the fix to this PR.

@jreback jreback merged commit 2e8c993 into pandas-dev:master Jul 11, 2016
@jreback
Copy link
Contributor

jreback commented Jul 11, 2016

thanks!

@sinhrks sinhrks deleted the nat_compare branch July 11, 2016 02:29
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: comparing 'NaT' in series with series returns True
3 participants