Skip to content

Commit 288efe9

Browse files
author
Oleh Kozynets
committed
Merge branch 'issue-36596' of https://github.com/OlehKSS/pandas into issue-36596
2 parents 0ddf563 + bd6e724 commit 288efe9

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

doc/source/whatsnew/v1.2.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ Numeric
434434
- Bug in :class:`DataFrame` allowing arithmetic operations with list of array-likes with undefined results. Behavior changed to raising ``ValueError`` (:issue:`36702`)
435435
- Bug in :meth:`DataFrame.std`` with ``timedelta64`` dtype and ``skipna=False`` (:issue:`37392`)
436436
- Bug in :meth:`DataFrame.min` and :meth:`DataFrame.max` with ``datetime64`` dtype and ``skipna=False`` (:issue:`36907`)
437+
- Bug in :func:`select_dtypes` different behavior between Windows and Linux with ``include="int"`` (:issue:`36569`)
437438

438439
Conversion
439440
^^^^^^^^^^

pandas/core/dtypes/common.py

+5
Original file line numberDiff line numberDiff line change
@@ -1796,6 +1796,11 @@ def pandas_dtype(dtype) -> DtypeObj:
17961796
# try a numpy dtype
17971797
# raise a consistent TypeError if failed
17981798
try:
1799+
# int is mapped to different types (int32, in64) on Windows and Linux
1800+
# see https://github.com/numpy/numpy/issues/9464
1801+
if (isinstance(dtype, str) and dtype == "int") or (dtype is int):
1802+
dtype = "int64"
1803+
17991804
npdtype = np.dtype(dtype)
18001805
except SyntaxError as err:
18011806
# np.dtype uses `eval` which can raise SyntaxError

pandas/tests/dtypes/test_common.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,22 @@ def test_invalid_dtype_error(self, box):
4343
com.pandas_dtype(box)
4444

4545
@pytest.mark.parametrize(
46-
"dtype",
46+
"dtype_input,dtype_output",
4747
[
48-
object,
49-
"float64",
50-
np.object_,
51-
np.dtype("object"),
52-
"O",
53-
np.float64,
54-
float,
55-
np.dtype("float64"),
48+
(object, object),
49+
("float64", np.float64),
50+
(np.object_, np.object_),
51+
(np.dtype("object"), np.object_),
52+
("O", object),
53+
(np.float64, np.float64),
54+
(float, float),
55+
(np.dtype("float64"), np.float64),
56+
("int", np.int64),
57+
(int, np.int64),
5658
],
5759
)
58-
def test_pandas_dtype_valid(self, dtype):
59-
assert com.pandas_dtype(dtype) == dtype
60+
def test_pandas_dtype_valid(self, dtype_input, dtype_output):
61+
assert com.pandas_dtype(dtype_input) == dtype_output
6062

6163
@pytest.mark.parametrize(
6264
"dtype", ["M8[ns]", "m8[ns]", "object", "float64", "int64"]

pandas/tests/frame/methods/test_select_dtypes.py

+6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ def test_select_dtypes_exclude_include_using_list_like(self):
8282
e = df[["b", "c", "e"]]
8383
tm.assert_frame_equal(r, e)
8484

85+
exclude = (np.datetime64,)
86+
include = np.bool_, "int"
87+
r = df.select_dtypes(include=include, exclude=exclude)
88+
e = df[["b", "e"]]
89+
tm.assert_frame_equal(r, e)
90+
8591
exclude = ("datetime",)
8692
include = "bool", "int64", "int32"
8793
r = df.select_dtypes(include=include, exclude=exclude)

0 commit comments

Comments
 (0)