Skip to content

incosistencies in dataframe.dtype.isin() - I am getting inconsistent with different runs on same code. #32443

Open
@maleknia

Description

@maleknia

Code Sample, a copy-pastable example if possible

import numpy as np
import pandas

data = [[2, 'tom', 10], [3, 'nick', 15], [4, 'juli', 14]]

myDf = pandas.DataFrame(data, columns=['a','b','c'])

print (myDf.dtypes)

print((myDf.dtypes.isin(['int64'])))

Problem description

Problem is that I am getting inconsistent results based on running the same code:

So first run gives me:

a  False
b  False
c  False

and second (sometimes it takes up to 10 attempts) run gives me:

a  True
b  False
c  True

the second case is the truth and matches the myDf.dtypes:

a     int64
b    object
c     int64

.

Again to reiterate, I am not changing the code but when I keep running the same code I sometime get the first output and sometime get the second output. This is while I do not change the input, code or interpreter. I tried it on different machines and interpreters and still getting the same inconsistent result

the version of Python 3.7
the version of Pandas: 1.0

Expected Output

Consistent result (as it sometimes matches with the current output).

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

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

pandas : 1.0.0
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 19.0.3
setuptools : 40.8.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugUpstream issueIssue related to pandas dependencyhashinghash_pandas_objectisinisin method

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions