pandas-dev/pandas (original) (raw)

Code Sample, a copy-pastable example if possible

In [1]: import pandas as pd

In [2]: pd.Timedelta(0) > pd.Timedelta(None)
TypeError: Cannot compare type Timedelta with type NaTType

In [3]: pd.Timedelta(None) < pd.Timedelta(0)
Out[3]: False

Problem description

I would expect the result of a < b to be the same as that of b > a but in this case one returns False and the other raises TypeError.

Related issue: #24983 "Separate NaT values for Timedelta and Period" - if pd.Timedelta(None) gave a value of type Timedelta then maybe this error would not have occurred.

Expected Output

Either both False or both TypeError (both False would be more helpful)

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.8.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-46-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8

pandas: 0.24.2
pytest: 4.3.1
pip: 19.0.3
setuptools: 40.8.0
Cython: 0.29.5
numpy: 1.16.2
scipy: None
pyarrow: None
xarray: 0.11.3
IPython: 7.3.0
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2018.9
blosc: None
bottleneck: None
tables: 3.4.4
numexpr: 2.6.9
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: None
html5lib: 1.0.1
sqlalchemy: 1.2.18
pymysql: None
psycopg2: 2.7.6.1 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None