Skip to content

BUG: TypeError in merge with timedelta64 column #13389

Closed
@b11z

Description

@b11z
>>> import pandas as pd
>>> df1 = pd.DataFrame({'entity_id': [101, 102]})
>>> df2 = pd.Series([None, None], index=[101, 102]).astype('timedelta64[D]').to_frame('days')
>>> print(df2); print(df2.dtypes)
     days
101   NaT
102   NaT
days    timedelta64[D]
dtype: object

>>> df1.merge(df2, left_on='entity_id', right_index=True)
...
  File "/Users/brian/src/pandas/pandas/core/common.py", line 95, in isnull
    return _isnull(obj)
  File "/Users/brian/src/pandas/pandas/core/common.py", line 105, in _isnull_new
    return _isnull_ndarraylike(obj)
  File "/Users/brian/src/pandas/pandas/core/common.py", line 196, in _isnull_ndarraylike
    result = np.isnan(values)
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Expected output:

   entity_id  days
0        101   NaT
1        102   NaT

INSTALLED VERSIONS

commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Darwin
OS-release: 15.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 22.0.5
Cython: None
numpy: 1.11.0
scipy: 0.17.0
statsmodels: None
xarray: None
IPython: 4.0.1
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: None
tables: None
numexpr: 2.5.1
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.10
pymysql: None
psycopg2: 2.6.1 (dt dec pq3 ext)
jinja2: 2.7.3
boto: 2.38.0
pandas_datareader: None

(It also appears on master)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReshapingConcat, Merge/Join, Stack/Unstack, ExplodeTimedeltaTimedelta data type

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions