Skip to content

Commit 0dc2660

Browse files
Terji PetersenTerji Petersen
Terji Petersen
authored and
Terji Petersen
committed
fix various
1 parent 3be51b9 commit 0dc2660

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

pandas/tests/groupby/test_groupby.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ def test_groupby_nonobject_dtype(mframe, df_mixed_floats):
9393
result = grouped.sum()
9494

9595
expected = mframe.groupby(key.astype("O")).sum()
96-
tm.assert_frame_equal(result, expected)
96+
assert result.index.dtype == np.int8
97+
assert expected.index.dtype == np.int64
98+
tm.assert_frame_equal(result, expected, check_index_type=False)
9799

98100
# GH 3911, mixed frame non-conversion
99101
df = df_mixed_floats.copy()
@@ -228,6 +230,7 @@ def test_pass_args_kwargs_duplicate_columns(tsframe, as_index):
228230
2: tsframe[tsframe.index.month == 2].quantile(0.8),
229231
}
230232
expected = DataFrame(ex_data).T
233+
expected.index = expected.index.astype(np.int32)
231234
if not as_index:
232235
# TODO: try to get this more consistent?
233236
expected.index = Index(range(2))
@@ -2813,7 +2816,7 @@ def test_groupby_overflow(val, dtype):
28132816
result = df.groupby("a").sum()
28142817
expected = DataFrame(
28152818
{"b": [val * 2]},
2816-
index=Index([1], name="a", dtype=f"{dtype}64"),
2819+
index=Index([1], name="a", dtype=f"{dtype}8"),
28172820
dtype=f"{dtype}64",
28182821
)
28192822
tm.assert_frame_equal(result, expected)
@@ -2825,7 +2828,7 @@ def test_groupby_overflow(val, dtype):
28252828
result = df.groupby("a").prod()
28262829
expected = DataFrame(
28272830
{"b": [val * val]},
2828-
index=Index([1], name="a", dtype=f"{dtype}64"),
2831+
index=Index([1], name="a", dtype=f"{dtype}8"),
28292832
dtype=f"{dtype}64",
28302833
)
28312834
tm.assert_frame_equal(result, expected)

pandas/tests/groupby/transform/test_transform.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def test_transform_datetime_to_numeric():
311311
lambda x: x.dt.dayofweek - x.dt.dayofweek.min()
312312
)
313313

314-
expected = Series([0, 1], name="b")
314+
expected = Series([0, 1], dtype=np.int32, name="b")
315315
tm.assert_series_equal(result, expected)
316316

317317

pandas/tests/indexing/multiindex/test_partial.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ def test_getitem_intkey_leading_level(
160160
mi = ser.index
161161
assert isinstance(mi, MultiIndex)
162162
if dtype is int:
163-
assert isinstance(mi.levels[0], Int64Index)
163+
assert mi.levels[0].dtype == np.int64
164164
else:
165-
assert isinstance(mi.levels[0], Float64Index)
165+
assert mi.levels[0].dtype == np.float64
166166

167167
assert 14 not in mi.levels[0]
168168
assert not mi.levels[0]._should_fallback_to_positional

pandas/tests/indexing/test_loc.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def test_loc_to_fail(self):
437437

438438
# raise a KeyError?
439439
msg = (
440-
r"\"None of \[Int64Index\(\[1, 2\], dtype='int64'\)\] are "
440+
r"\"None of \[NumericIndex\(\[1, 2\], dtype='int64'\)\] are "
441441
r"in the \[index\]\""
442442
)
443443
with pytest.raises(KeyError, match=msg):
@@ -455,7 +455,7 @@ def test_loc_to_fail2(self):
455455
s.loc[-1]
456456

457457
msg = (
458-
r"\"None of \[Int64Index\(\[-1, -2\], dtype='int64'\)\] are "
458+
r"\"None of \[NumericIndex\(\[-1, -2\], dtype='int64'\)\] are "
459459
r"in the \[index\]\""
460460
)
461461
with pytest.raises(KeyError, match=msg):
@@ -471,7 +471,7 @@ def test_loc_to_fail2(self):
471471

472472
s["a"] = 2
473473
msg = (
474-
r"\"None of \[Int64Index\(\[-2\], dtype='int64'\)\] are "
474+
r"\"None of \[NumericIndex\(\[-2\], dtype='int64'\)\] are "
475475
r"in the \[index\]\""
476476
)
477477
with pytest.raises(KeyError, match=msg):
@@ -488,7 +488,7 @@ def test_loc_to_fail3(self):
488488
df = DataFrame([["a"], ["b"]], index=[1, 2], columns=["value"])
489489

490490
msg = (
491-
r"\"None of \[Int64Index\(\[3\], dtype='int64'\)\] are "
491+
r"\"None of \[NumericIndex\(\[3\], dtype='int64'\)\] are "
492492
r"in the \[index\]\""
493493
)
494494
with pytest.raises(KeyError, match=msg):
@@ -508,7 +508,7 @@ def test_loc_getitem_list_with_fail(self):
508508
with pytest.raises(
509509
KeyError,
510510
match=re.escape(
511-
"\"None of [Int64Index([3], dtype='int64')] are in the [index]\""
511+
"\"None of [NumericIndex([3], dtype='int64')] are in the [index]\""
512512
),
513513
):
514514
s.loc[[3]]
@@ -1218,7 +1218,7 @@ def test_loc_setitem_empty_append_raises(self):
12181218
df = DataFrame(columns=["x", "y"])
12191219
df.index = df.index.astype(np.int64)
12201220
msg = (
1221-
r"None of \[Int64Index\(\[0, 1\], dtype='int64'\)\] "
1221+
r"None of \[NumericIndex\(\[0, 1\], dtype='int64'\)\] "
12221222
r"are in the \[index\]"
12231223
)
12241224
with pytest.raises(KeyError, match=msg):

pandas/tests/indexing/test_partial.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def test_series_partial_set(self):
403403

404404
# raises as nothing is in the index
405405
msg = (
406-
r"\"None of \[Int64Index\(\[3, 3, 3\], dtype='int64'\)\] are "
406+
r"\"None of \[NumericIndex\(\[3, 3, 3\], dtype='int64'\)\] are "
407407
r"in the \[index\]\""
408408
)
409409
with pytest.raises(KeyError, match=msg):
@@ -484,7 +484,7 @@ def test_series_partial_set_with_name(self):
484484

485485
# raises as nothing is in the index
486486
msg = (
487-
r"\"None of \[Int64Index\(\[3, 3, 3\], dtype='int64', "
487+
r"\"None of \[NumericIndex\(\[3, 3, 3\], dtype='int64', "
488488
r"name='idx'\)\] are in the \[index\]\""
489489
)
490490
with pytest.raises(KeyError, match=msg):

pandas/tests/resample/test_resample_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ def test_selection_api_validation():
648648
# non DatetimeIndex
649649
msg = (
650650
"Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, "
651-
"but got an instance of 'Int64Index'"
651+
"but got an instance of 'NumericIndex'"
652652
)
653653
with pytest.raises(TypeError, match=msg):
654654
df.resample("2D", level="v")

0 commit comments

Comments
 (0)