Skip to content

Commit

Permalink
see if intp fixes int32 problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Terji Petersen authored and Terji Petersen committed Nov 7, 2022
1 parent b332214 commit 8b52054
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def _ensure_array(cls, data, dtype, copy: bool):
data = data.copy()
return data

@final
# @final (temporary off until merge NumericIndex into Index
@classmethod
def _dtype_to_subclass(cls, dtype: DtypeObj):
# Delay import for perf. https://github.com/pandas-dev/pandas/pull/31423
Expand Down Expand Up @@ -1051,6 +1051,7 @@ def astype(self, dtype, copy: bool = True):
UInt64Index,
)

klass: Index
if is_signed_integer_dtype(dtype):
klass = Int64Index
elif is_unsigned_integer_dtype(dtype):
Expand Down
5 changes: 4 additions & 1 deletion pandas/tests/window/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,10 @@ def test_nan_and_zero_endpoints(self):
arr,
name="adl2",
index=MultiIndex.from_arrays(
[[0] * 999 + [1], [0] * 999 + [1]], names=["index", "index"]
[
Index([0] * 999 + [1], dtype=np.intp, name="index"),
Index([0] * 999 + [1], dtype=np.intp, name="index"),
],
),
)
tm.assert_series_equal(result, expected)
Expand Down
7 changes: 6 additions & 1 deletion pandas/tests/window/test_pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_flex_binary_frame(method, frame):
exp = DataFrame(
{k: getattr(frame[k].rolling(window=10), method)(frame2[k]) for k in frame}
)
exp.columns = exp.columns.astype(np.intp)
tm.assert_frame_equal(res3, exp)


Expand Down Expand Up @@ -431,7 +432,11 @@ def test_multindex_columns_pairwise_func(self):
expected = DataFrame(
np.nan,
index=MultiIndex.from_arrays(
[np.repeat(np.arange(5), 2), ["M", "N"] * 5, ["P", "Q"] * 5],
[
np.repeat(np.arange(5, dtype=np.int64), 2),
["M", "N"] * 5,
["P", "Q"] * 5,
],
names=[None, "a", "b"],
),
columns=columns,
Expand Down

0 comments on commit 8b52054

Please sign in to comment.