Skip to content

BUG: select_dtypes(include="int") has different behaviour on windows and linux #36596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
JoschD opened this issue Sep 24, 2020 · 3 comments · Fixed by #36808
Closed
2 tasks done

BUG: select_dtypes(include="int") has different behaviour on windows and linux #36596

JoschD opened this issue Sep 24, 2020 · 3 comments · Fixed by #36808
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Windows Windows OS
Milestone

Comments

@JoschD
Copy link

JoschD commented Sep 24, 2020

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version (1.1.2) of pandas.


Problem description

Using DataFrame.select_dtypes(include='int') on a DataFrame that contains an integer column returns an empty dataframe in windows, yet selects the correct columns in linux (Ubuntu 20.04).

DataFrame.select_dtypes(include='integer') works as expected in both environments.

In both cases the dtype of the column is 'int64'.

Code Sample, a copy-pastable example

df = pd.DataFrame(columns=["Ints"], data=[1,2,3])
df.select_dtypes(include="int")

Output

on ubuntu (tested 16.04, 18.04, 20.04, python 3.6, 3.7, 3.8)

   Ints
0     1
1     2
2     3

on windows 10 (python 3.6, 3.7. 3.8)

Empty DataFrame
Columns: []
Index: [0, 1, 2]

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 2a7d332
python : 3.8.6.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 126 Stepping 5, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_Europe.1252

pandas : 1.1.2
numpy : 1.19.2
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.1
setuptools : 49.2.1
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 : 7.18.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

INSTALLED VERSIONS

commit : 2a7d332
python : 3.7.8.final.0
python-bits : 64
OS : Linux
OS-release : 4.19.104-microsoft-standard
Version : #1 SMP Wed Feb 19 06:37:35 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.1.2
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 47.1.0
Cython : None
pytest : 5.4.3
hypothesis : 5.20.3
sphinx : 3.1.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.16.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

@JoschD JoschD added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 24, 2020
@simonjayhawkins
Copy link
Member

Thanks @JoschD for the report. see also #29394

@simonjayhawkins simonjayhawkins added Dtype Conversions Unexpected or buggy dtype conversions Windows Windows OS and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 24, 2020
@simonjayhawkins simonjayhawkins added this to the Contributions Welcome milestone Sep 24, 2020
@OlehKSS
Copy link
Contributor

OlehKSS commented Sep 30, 2020

Hi, does anyone work on this issue?

I have found that this problem is due to the fact that numpy.dtype('int') returns different values on Windows and Linux, 'dtype(int32)' and 'dtype(int64)' respectively. This is the line that generates this problem. I didn't see any mentioning of this bug in numpy's repository, it is reproducible on the master branch of numpy. As a workaround we might just treat int32 as int64, provided it's not a big problem.

@OlehKSS
Copy link
Contributor

OlehKSS commented Oct 2, 2020

This bug is related to numpy/numpy#9464
I have opened a pull request fixing this issue #36808

@jreback jreback modified the milestones: Contributions Welcome, 1.3 Feb 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Windows Windows OS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants