BUG: comparing 'NaT' in series with series returns True · Issue #9005 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@jorisvandenbossche

Description

@jorisvandenbossche

xref #12877 (test on Series & DataFrame)

When having a 'NaT' in a datetime series and comparing this to a datetime series, the comparison with NaT returns True (and shouldn't comparisons with NA not always return False?) Comparing it with a scalar does return False:

In [54]: s = pd.Series([pd.Timestamp('2012-01-01'), pd.Timestamp('NaT')])
In [55]: s2 = pd.Series([pd.Timestamp('2013-01-01'), pd.Timestamp('2014-01-01')])

In [57]: s
Out[57]:
0   2012-01-01
1          NaT
dtype: datetime64[ns]

In [58]: s2
Out[58]:
0   2013-01-01
1   2014-01-01
dtype: datetime64[ns]

In [59]: s < s2
Out[59]:
0    True
1    True
dtype: bool

In [60]: s < pd.Timestamp('2013-01-01')
Out[60]:
0     True
1    False
dtype: bool

Original from http://stackoverflow.com/questions/27305324/pandas-comparison-with-variable-number-of-columns/27305661#27305661