import pandas as pd
import datetime as dt

d = pd.DataFrame([[1, dt.datetime(1990,12,10)],
                  [2, dt.datetime(1990,12,11)]])
s = d.loc[0].copy()

d == s

TypeError: int() argument must be a string, a bytes-like object or a number, not 'Timestamp'

Problem description

When trying to check if a series is equal to one row in a dataframe containing values of type datetime.datetime and values of other types, pandas breaks. It works if the datetime values are substituted with str type (that's what I have tried, don't know about other types). Also comparing the .values works e.g.

d = pd.DataFrame([[1, dt.datetime(1990,12,10)],
                  [2, dt.datetime(1990,12,11)]])
s = d.loc[0].copy()

d.values == s.values

Works as expected

Expected Output

       0     1
0   True  True
1  False  False

Output of pd.show_versions()

commit: None python: 3.6.0.final.0 python-bits: 64 OS: Linux OS-release: 4.4.0-93-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 pandas: 0.20.3 pytest: 3.0.7 pip: 9.0.1 setuptools: 27.2.0 Cython: 0.25.2 numpy: 1.13.1 scipy: 0.19.1 xarray: None IPython: 5.1.0 sphinx: 1.5.1 patsy: 0.4.1 dateutil: 2.6.0 pytz: 2016.10 blosc: None bottleneck: 1.2.1 tables: 3.4.2 numexpr: 2.6.2 feather: None matplotlib: 2.0.2 openpyxl: 2.4.1 xlrd: 1.0.0 xlwt: 1.2.0 xlsxwriter: 0.9.6 lxml: 3.7.2 bs4: 4.5.3 html5lib: 0.9999999 sqlalchemy: 1.1.13 pymysql: None psycopg2: None jinja2: 2.9.4 s3fs: None pandas_gbq: None pandas_datareader: None

Comment From: pratapvardhan

d.eq(s) for comparison should work for you.

In [805]: d = pd.DataFrame([[1, dt.datetime(1990,12,10)],
     ...:                   [2, dt.datetime(1990,12,11)]])
     ...: s = d.loc[0].copy()
     ...:

In [806]: d.eq(s)
Out[806]:
       0      1
0   True   True
1  False  False

Comment From: gionatarogiani

I tried, but it breaks raising the same error

Comment From: pratapvardhan

Check the updated comment. It works fine on master branch. What's the error?

Comment From: jreback

In [7]: d
Out[7]: 
   0          1
0  1 1990-12-10
1  2 1990-12-11

In [8]: d.eq(s, axis=1)
Out[8]: 
       0      1
0   True   True
1  False  False

In [9]: d.eq(s, axis=0)
Out[9]: 
       0      1
0   True  False
1  False  False

Comment From: jreback

http://pandas.pydata.org/pandas-docs/stable/basics.html#flexible-comparisons are the docs

Comment From: SimonBaron

@pratapvardhan I aslo see this error in python 2.7 if I run

d = pd.DataFrame([[1, dt.datetime(1990,12,10)],
                  [2, dt.datetime(1990,12,11)]])
s = d.loc[0].copy()


print d.eq(s)

I get

TypeError: long() argument must be a string or a number, not 'Timestamp'

edit: didn't realise that I'm a version behind on pandas though. still on 19

edit2: updating pandas and datetime doesn't fix this @jreback, axis=0 works as expected, axis=1 gives the error described.

Comment From: gionatarogiani

@SimonBaron Same here, works with axis=0 but not with axis=1.
I think the problem is that my installed version and the latest available through pip or conda is 0.20.3. Sorry for opening a issue while working on an old version.