Skip to content

Commit 0f2d5a5

Browse files
authored
Remove int64/uint64/float64 indexes from tests/resample & tests/reshape (#50823)
1 parent 99bda74 commit 0f2d5a5

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

pandas/tests/resample/test_resampler_grouper.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
Timestamp,
1616
)
1717
import pandas._testing as tm
18-
from pandas.core.api import Int64Index
1918
from pandas.core.indexes.datetimes import date_range
2019

2120
test_frame = DataFrame(
@@ -333,7 +332,7 @@ def test_consistency_with_window():
333332

334333
# consistent return values with window
335334
df = test_frame
336-
expected = Int64Index([1, 2, 3], name="A")
335+
expected = Index([1, 2, 3], name="A")
337336
result = df.groupby("A").resample("2s").mean()
338337
assert result.index.nlevels == 2
339338
tm.assert_index_equal(result.index.levels[0], expected)

pandas/tests/reshape/merge/test_merge.py

+15-16
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
CategoricalIndex,
2121
DataFrame,
2222
DatetimeIndex,
23+
Index,
2324
IntervalIndex,
2425
MultiIndex,
2526
PeriodIndex,
@@ -29,11 +30,6 @@
2930
)
3031
import pandas._testing as tm
3132
from pandas.api.types import CategoricalDtype as CDT
32-
from pandas.core.api import (
33-
Float64Index,
34-
Int64Index,
35-
UInt64Index,
36-
)
3733
from pandas.core.reshape.concat import concat
3834
from pandas.core.reshape.merge import (
3935
MergeError,
@@ -1324,8 +1320,13 @@ def test_merge_two_empty_df_no_division_error(self):
13241320
["2001-01-01", "2002-02-02", "2003-03-03", pd.NaT, pd.NaT, pd.NaT]
13251321
),
13261322
),
1327-
(Float64Index([1, 2, 3]), Float64Index([1, 2, 3, None, None, None])),
1328-
(Int64Index([1, 2, 3]), Float64Index([1, 2, 3, None, None, None])),
1323+
*[
1324+
(
1325+
Index([1, 2, 3], dtype=dtyp),
1326+
Index([1, 2, 3, None, None, None], dtype=np.float64),
1327+
)
1328+
for dtyp in tm.ALL_REAL_NUMPY_DTYPES
1329+
],
13291330
(
13301331
IntervalIndex.from_tuples([(1, 2), (2, 3), (3, 4)]),
13311332
IntervalIndex.from_tuples(
@@ -2142,15 +2143,13 @@ def test_merge_on_indexes(self, left_df, right_df, how, sort, expected):
21422143

21432144
@pytest.mark.parametrize(
21442145
"index",
2145-
[
2146+
[Index([1, 2], dtype=dtyp, name="index_col") for dtyp in tm.ALL_REAL_NUMPY_DTYPES]
2147+
+ [
21462148
CategoricalIndex(["A", "B"], categories=["A", "B"], name="index_col"),
2147-
Float64Index([1.0, 2.0], name="index_col"),
2148-
Int64Index([1, 2], name="index_col"),
2149-
UInt64Index([1, 2], name="index_col"),
21502149
RangeIndex(start=0, stop=2, name="index_col"),
21512150
DatetimeIndex(["2018-01-01", "2018-01-02"], name="index_col"),
21522151
],
2153-
ids=lambda x: type(x).__name__,
2152+
ids=lambda x: f"{type(x).__name__}[{x.dtype}]",
21542153
)
21552154
def test_merge_index_types(index):
21562155
# gh-20777
@@ -2652,11 +2651,11 @@ def test_merge_duplicate_columns_with_suffix_causing_another_duplicate_raises():
26522651

26532652
def test_merge_string_float_column_result():
26542653
# GH 13353
2655-
df1 = DataFrame([[1, 2], [3, 4]], columns=pd.Index(["a", 114.0]))
2654+
df1 = DataFrame([[1, 2], [3, 4]], columns=Index(["a", 114.0]))
26562655
df2 = DataFrame([[9, 10], [11, 12]], columns=["x", "y"])
26572656
result = merge(df2, df1, how="inner", left_index=True, right_index=True)
26582657
expected = DataFrame(
2659-
[[9, 10, 1, 2], [11, 12, 3, 4]], columns=pd.Index(["x", "y", "a", 114.0])
2658+
[[9, 10, 1, 2], [11, 12, 3, 4]], columns=Index(["x", "y", "a", 114.0])
26602659
)
26612660
tm.assert_frame_equal(result, expected)
26622661

@@ -2712,8 +2711,8 @@ def test_merge_outer_with_NaN(dtype):
27122711

27132712
def test_merge_different_index_names():
27142713
# GH#45094
2715-
left = DataFrame({"a": [1]}, index=pd.Index([1], name="c"))
2716-
right = DataFrame({"a": [1]}, index=pd.Index([1], name="d"))
2714+
left = DataFrame({"a": [1]}, index=Index([1], name="c"))
2715+
right = DataFrame({"a": [1]}, index=Index([1], name="d"))
27172716
result = merge(left, right, left_on="c", right_on="d")
27182717
expected = DataFrame({"a_x": [1], "a_y": 1})
27192718
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)