Skip to content

Commit 2a35877

Browse files
Terji Petersentopper-123
Terji Petersen
authored andcommitted
remove Int/Uint/Float64Index from pandas/tests/reshape
1 parent 00051c3 commit 2a35877

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

pandas/tests/reshape/merge/test_merge.py

+23-20
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(
@@ -2140,17 +2141,19 @@ def test_merge_on_indexes(self, left_df, right_df, how, sort, expected):
21402141
tm.assert_frame_equal(result, expected)
21412142

21422143

2144+
_test_merge_index_types_params = [
2145+
Index([1, 2], dtype=dtyp, name="index_col") for dtyp in tm.ALL_REAL_NUMPY_DTYPES
2146+
] + [
2147+
CategoricalIndex(["A", "B"], categories=["A", "B"], name="index_col"),
2148+
RangeIndex(start=0, stop=2, name="index_col"),
2149+
DatetimeIndex(["2018-01-01", "2018-01-02"], name="index_col"),
2150+
]
2151+
2152+
21432153
@pytest.mark.parametrize(
21442154
"index",
2145-
[
2146-
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"),
2150-
RangeIndex(start=0, stop=2, name="index_col"),
2151-
DatetimeIndex(["2018-01-01", "2018-01-02"], name="index_col"),
2152-
],
2153-
ids=lambda x: type(x).__name__,
2155+
_test_merge_index_types_params,
2156+
ids=lambda x: f"{type(x).__name__}[{x.dtype}]",
21542157
)
21552158
def test_merge_index_types(index):
21562159
# gh-20777
@@ -2652,11 +2655,11 @@ def test_merge_duplicate_columns_with_suffix_causing_another_duplicate_raises():
26522655

26532656
def test_merge_string_float_column_result():
26542657
# GH 13353
2655-
df1 = DataFrame([[1, 2], [3, 4]], columns=pd.Index(["a", 114.0]))
2658+
df1 = DataFrame([[1, 2], [3, 4]], columns=Index(["a", 114.0]))
26562659
df2 = DataFrame([[9, 10], [11, 12]], columns=["x", "y"])
26572660
result = merge(df2, df1, how="inner", left_index=True, right_index=True)
26582661
expected = DataFrame(
2659-
[[9, 10, 1, 2], [11, 12, 3, 4]], columns=pd.Index(["x", "y", "a", 114.0])
2662+
[[9, 10, 1, 2], [11, 12, 3, 4]], columns=Index(["x", "y", "a", 114.0])
26602663
)
26612664
tm.assert_frame_equal(result, expected)
26622665

@@ -2712,8 +2715,8 @@ def test_merge_outer_with_NaN(dtype):
27122715

27132716
def test_merge_different_index_names():
27142717
# GH#45094
2715-
left = DataFrame({"a": [1]}, index=pd.Index([1], name="c"))
2716-
right = DataFrame({"a": [1]}, index=pd.Index([1], name="d"))
2718+
left = DataFrame({"a": [1]}, index=Index([1], name="c"))
2719+
right = DataFrame({"a": [1]}, index=Index([1], name="d"))
27172720
result = merge(left, right, left_on="c", right_on="d")
27182721
expected = DataFrame({"a_x": [1], "a_y": 1})
27192722
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)