|
20 | 20 | CategoricalIndex, |
21 | 21 | DataFrame, |
22 | 22 | DatetimeIndex, |
| 23 | + Index, |
23 | 24 | IntervalIndex, |
24 | 25 | MultiIndex, |
25 | 26 | PeriodIndex, |
|
29 | 30 | ) |
30 | 31 | import pandas._testing as tm |
31 | 32 | from pandas.api.types import CategoricalDtype as CDT |
32 | | -from pandas.core.api import ( |
33 | | - Float64Index, |
34 | | - Int64Index, |
35 | | - UInt64Index, |
36 | | -) |
37 | 33 | from pandas.core.reshape.concat import concat |
38 | 34 | from pandas.core.reshape.merge import ( |
39 | 35 | MergeError, |
@@ -1324,8 +1320,13 @@ def test_merge_two_empty_df_no_division_error(self): |
1324 | 1320 | ["2001-01-01", "2002-02-02", "2003-03-03", pd.NaT, pd.NaT, pd.NaT] |
1325 | 1321 | ), |
1326 | 1322 | ), |
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 | + ], |
1329 | 1330 | ( |
1330 | 1331 | IntervalIndex.from_tuples([(1, 2), (2, 3), (3, 4)]), |
1331 | 1332 | IntervalIndex.from_tuples( |
@@ -2142,15 +2143,13 @@ def test_merge_on_indexes(self, left_df, right_df, how, sort, expected): |
2142 | 2143 |
|
2143 | 2144 | @pytest.mark.parametrize( |
2144 | 2145 | "index", |
2145 | | - [ |
| 2146 | + [Index([1, 2], dtype=dtyp, name="index_col") for dtyp in tm.ALL_REAL_NUMPY_DTYPES] |
| 2147 | + + [ |
2146 | 2148 | 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 | 2149 | RangeIndex(start=0, stop=2, name="index_col"), |
2151 | 2150 | DatetimeIndex(["2018-01-01", "2018-01-02"], name="index_col"), |
2152 | 2151 | ], |
2153 | | - ids=lambda x: type(x).__name__, |
| 2152 | + ids=lambda x: f"{type(x).__name__}[{x.dtype}]", |
2154 | 2153 | ) |
2155 | 2154 | def test_merge_index_types(index): |
2156 | 2155 | # gh-20777 |
@@ -2652,11 +2651,11 @@ def test_merge_duplicate_columns_with_suffix_causing_another_duplicate_raises(): |
2652 | 2651 |
|
2653 | 2652 | def test_merge_string_float_column_result(): |
2654 | 2653 | # 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])) |
2656 | 2655 | df2 = DataFrame([[9, 10], [11, 12]], columns=["x", "y"]) |
2657 | 2656 | result = merge(df2, df1, how="inner", left_index=True, right_index=True) |
2658 | 2657 | 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]) |
2660 | 2659 | ) |
2661 | 2660 | tm.assert_frame_equal(result, expected) |
2662 | 2661 |
|
@@ -2712,8 +2711,8 @@ def test_merge_outer_with_NaN(dtype): |
2712 | 2711 |
|
2713 | 2712 | def test_merge_different_index_names(): |
2714 | 2713 | # 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")) |
2717 | 2716 | result = merge(left, right, left_on="c", right_on="d") |
2718 | 2717 | expected = DataFrame({"a_x": [1], "a_y": 1}) |
2719 | 2718 | tm.assert_frame_equal(result, expected) |
|
0 commit comments