Code Sample, a copy-pastable example if possible

# Your code here

import pandas as pd
import numpy as np

# create a dateframe with a column "duration", which contains timedelta of 5 minutes
p=pd.DataFrame({"duration":[np.timedelta64(5, "m")]})

# compare this column with timedelta of 4 minutes
p.duration<np.timedelta64(4, "m")

#this should result in a series of one bool which is false.

Problem description

When you try to compare a column of np.timedelta64 with a single np.timedelta64, version 0.22.0 throws

ValueError: cannot set a Timedelta with a non-timedelta

This worked in previous version 0.20.3 and returned the correct series of bools

Expected Output

This is the output as of version 0.20.3

0 False Name: duration, dtype: bool

Output of pd.show_versions()

>>> pd.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 2.7.11.final.0 python-bits: 64 OS: Windows OS-release: 7 machine: AMD64 processor: Intel64 Family 6 Model 60 Stepping 3, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None pandas: 0.22.0 pytest: 2.7.1 pip: 9.0.1 setuptools: 36.4.0 Cython: 0.22.1 numpy: 1.11.3 scipy: 0.19.0 pyarrow: None xarray: None IPython: 4.0.0 sphinx: 1.3.1 patsy: 0.4.1 dateutil: 2.4.1 pytz: 2017.2 blosc: None bottleneck: 1.2.1 tables: 3.4.2 numexpr: 2.6.2 feather: None matplotlib: 1.5.1 openpyxl: 1.8.5 xlrd: 0.9.3 xlwt: 1.0.0 xlsxwriter: 0.7.3 lxml: 3.6.0 bs4: 4.6.0 html5lib: None sqlalchemy: 1.0.12 pymysql: 0.6.7.None psycopg2: None jinja2: 2.8 s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: None

Comment From: jreback

this is as expected. a np.timedelta64 is unit less so the comparison doesn't make sense. you can use np.timedelta64(1, 'ns') or whatever unit, or more idiomatic a pd.Timedelta

Comment From: DavidTolan

@jreback If you look at the code I am comparing the data in the column which is np.timedelta64(5, "m") with np.timedelta64(4, "m") this is NOT unit less. Again, this worked in 0.20.3 the comparison is meaningful 4 minutes is less than 5 minutes.

Comment From: jreback

I c. actually this is not working on 0.22, but is in master (0.23.0 coming soon). this has had extensive refactoring.

Comment From: DavidTolan

Cool. I had a quick look at the source code & decided it was not a 10 second fix 🤔