From e3492a7ebf43fb550cedb64e471be6dc0d2da4d1 Mon Sep 17 00:00:00 2001 From: "alexprincel@gmail.com" Date: Tue, 23 Feb 2021 12:05:23 -0500 Subject: [PATCH] STYLE: Inconsistent namespace - Indexes (#39992) --- pandas/tests/indexes/common.py | 8 ++-- .../indexes/datetimes/methods/test_astype.py | 4 +- .../indexes/datetimes/test_constructors.py | 4 +- .../indexes/datetimes/test_date_range.py | 2 +- .../tests/indexes/datetimes/test_datetime.py | 4 +- pandas/tests/indexes/multi/test_conversion.py | 4 +- pandas/tests/indexes/multi/test_drop.py | 2 +- .../tests/indexes/multi/test_equivalence.py | 6 +-- pandas/tests/indexes/multi/test_join.py | 13 +++--- pandas/tests/indexes/multi/test_reindex.py | 10 ++--- pandas/tests/indexes/multi/test_reshape.py | 4 +- pandas/tests/indexes/multi/test_setops.py | 42 +++++++++---------- pandas/tests/indexes/period/test_setops.py | 2 +- pandas/tests/indexes/test_base.py | 28 ++++++------- 14 files changed, 66 insertions(+), 67 deletions(-) diff --git a/pandas/tests/indexes/common.py b/pandas/tests/indexes/common.py index 0354e362dc4ac..001b5225379ee 100644 --- a/pandas/tests/indexes/common.py +++ b/pandas/tests/indexes/common.py @@ -360,7 +360,7 @@ def test_numpy_repeat(self): @pytest.mark.parametrize("klass", [list, tuple, np.array, Series]) def test_where(self, klass): i = self.create_index() - if isinstance(i, (pd.DatetimeIndex, pd.TimedeltaIndex)): + if isinstance(i, (DatetimeIndex, TimedeltaIndex)): # where does not preserve freq i = i._with_freq(None) @@ -611,7 +611,7 @@ def test_map(self): index = self.create_index() # we don't infer UInt64 - if isinstance(index, pd.UInt64Index): + if isinstance(index, UInt64Index): expected = index.astype("int64") else: expected = index @@ -630,13 +630,13 @@ def test_map(self): def test_map_dictlike(self, mapper): index = self.create_index() - if isinstance(index, pd.CategoricalIndex): + if isinstance(index, CategoricalIndex): pytest.skip(f"skipping tests for {type(index)}") identity = mapper(index.values, index) # we don't infer to UInt64 for a dict - if isinstance(index, pd.UInt64Index) and isinstance(identity, dict): + if isinstance(index, UInt64Index) and isinstance(identity, dict): expected = index.astype("int64") else: expected = index diff --git a/pandas/tests/indexes/datetimes/methods/test_astype.py b/pandas/tests/indexes/datetimes/methods/test_astype.py index bed7cb9b54eba..0d241b7bc7f83 100644 --- a/pandas/tests/indexes/datetimes/methods/test_astype.py +++ b/pandas/tests/indexes/datetimes/methods/test_astype.py @@ -202,13 +202,13 @@ def test_astype_object_tz(self, tz): def test_astype_object_with_nat(self): idx = DatetimeIndex( - [datetime(2013, 1, 1), datetime(2013, 1, 2), pd.NaT, datetime(2013, 1, 4)], + [datetime(2013, 1, 1), datetime(2013, 1, 2), NaT, datetime(2013, 1, 4)], name="idx", ) expected_list = [ Timestamp("2013-01-01"), Timestamp("2013-01-02"), - pd.NaT, + NaT, Timestamp("2013-01-04"), ] expected = Index(expected_list, dtype=object, name="idx") diff --git a/pandas/tests/indexes/datetimes/test_constructors.py b/pandas/tests/indexes/datetimes/test_constructors.py index 3f30a1a076eda..c1b437048343d 100644 --- a/pandas/tests/indexes/datetimes/test_constructors.py +++ b/pandas/tests/indexes/datetimes/test_constructors.py @@ -506,8 +506,8 @@ def test_construction_outofbounds(self): def test_construction_with_ndarray(self): # GH 5152 dates = [datetime(2013, 10, 7), datetime(2013, 10, 8), datetime(2013, 10, 9)] - data = DatetimeIndex(dates, freq=pd.offsets.BDay()).values - result = DatetimeIndex(data, freq=pd.offsets.BDay()) + data = DatetimeIndex(dates, freq=offsets.BDay()).values + result = DatetimeIndex(data, freq=offsets.BDay()) expected = DatetimeIndex(["2013-10-07", "2013-10-08", "2013-10-09"], freq="B") tm.assert_index_equal(result, expected) diff --git a/pandas/tests/indexes/datetimes/test_date_range.py b/pandas/tests/indexes/datetimes/test_date_range.py index b8def8072a3b7..2c0a29ad25c4c 100644 --- a/pandas/tests/indexes/datetimes/test_date_range.py +++ b/pandas/tests/indexes/datetimes/test_date_range.py @@ -1009,7 +1009,7 @@ def test_range_with_millisecond_resolution(self, start_end): def test_date_range_with_custom_holidays(): # GH 30593 - freq = pd.offsets.CustomBusinessHour(start="15:00", holidays=["2020-11-26"]) + freq = offsets.CustomBusinessHour(start="15:00", holidays=["2020-11-26"]) result = date_range(start="2020-11-25 15:00", periods=4, freq=freq) expected = DatetimeIndex( [ diff --git a/pandas/tests/indexes/datetimes/test_datetime.py b/pandas/tests/indexes/datetimes/test_datetime.py index 846bca2ecf2f6..f6533daa553f7 100644 --- a/pandas/tests/indexes/datetimes/test_datetime.py +++ b/pandas/tests/indexes/datetimes/test_datetime.py @@ -210,7 +210,7 @@ def test_asarray_tz_naive(self): # optionally, object result = np.asarray(idx, dtype=object) - expected = np.array([pd.Timestamp("2000-01-01"), pd.Timestamp("2000-01-02")]) + expected = np.array([Timestamp("2000-01-01"), Timestamp("2000-01-02")]) tm.assert_numpy_array_equal(result, expected) def test_asarray_tz_aware(self): @@ -228,7 +228,7 @@ def test_asarray_tz_aware(self): # Future behavior with no warning expected = np.array( - [pd.Timestamp("2000-01-01", tz=tz), pd.Timestamp("2000-01-02", tz=tz)] + [Timestamp("2000-01-01", tz=tz), Timestamp("2000-01-02", tz=tz)] ) result = np.asarray(idx, dtype=object) diff --git a/pandas/tests/indexes/multi/test_conversion.py b/pandas/tests/indexes/multi/test_conversion.py index c80548783d148..9167cd6c3b786 100644 --- a/pandas/tests/indexes/multi/test_conversion.py +++ b/pandas/tests/indexes/multi/test_conversion.py @@ -87,7 +87,7 @@ def test_to_frame(): def test_to_frame_dtype_fidelity(): # GH 22420 - mi = pd.MultiIndex.from_arrays( + mi = MultiIndex.from_arrays( [ pd.date_range("19910905", periods=6, tz="US/Eastern"), [1, 1, 1, 2, 2, 2], @@ -116,7 +116,7 @@ def test_to_frame_dtype_fidelity(): def test_to_frame_resulting_column_order(): # GH 22420 expected = ["z", 0, "a"] - mi = pd.MultiIndex.from_arrays( + mi = MultiIndex.from_arrays( [["a", "b", "c"], ["x", "y", "z"], ["q", "w", "e"]], names=expected ) result = mi.to_frame().columns.tolist() diff --git a/pandas/tests/indexes/multi/test_drop.py b/pandas/tests/indexes/multi/test_drop.py index 76d704737688d..fc74533ca8183 100644 --- a/pandas/tests/indexes/multi/test_drop.py +++ b/pandas/tests/indexes/multi/test_drop.py @@ -184,7 +184,7 @@ def test_single_level_drop_partially_missing_elements(): def test_droplevel_multiindex_one_level(): # GH#37208 - index = pd.MultiIndex.from_tuples([(2,)], names=("b",)) + index = MultiIndex.from_tuples([(2,)], names=("b",)) result = index.droplevel([]) expected = pd.Int64Index([2], name="b") tm.assert_index_equal(result, expected) diff --git a/pandas/tests/indexes/multi/test_equivalence.py b/pandas/tests/indexes/multi/test_equivalence.py index c44f7622c04dd..19e9bd94e67a1 100644 --- a/pandas/tests/indexes/multi/test_equivalence.py +++ b/pandas/tests/indexes/multi/test_equivalence.py @@ -219,11 +219,11 @@ def test_equals_missing_values(): def test_equals_missing_values_differently_sorted(): # GH#38439 - mi1 = pd.MultiIndex.from_tuples([(81.0, np.nan), (np.nan, np.nan)]) - mi2 = pd.MultiIndex.from_tuples([(np.nan, np.nan), (81.0, np.nan)]) + mi1 = MultiIndex.from_tuples([(81.0, np.nan), (np.nan, np.nan)]) + mi2 = MultiIndex.from_tuples([(np.nan, np.nan), (81.0, np.nan)]) assert not mi1.equals(mi2) - mi2 = pd.MultiIndex.from_tuples([(81.0, np.nan), (np.nan, np.nan)]) + mi2 = MultiIndex.from_tuples([(81.0, np.nan), (np.nan, np.nan)]) assert mi1.equals(mi2) diff --git a/pandas/tests/indexes/multi/test_join.py b/pandas/tests/indexes/multi/test_join.py index 6b6b9346fe1fe..f03057e6c6e44 100644 --- a/pandas/tests/indexes/multi/test_join.py +++ b/pandas/tests/indexes/multi/test_join.py @@ -1,7 +1,6 @@ import numpy as np import pytest -import pandas as pd from pandas import Index, MultiIndex import pandas._testing as tm @@ -51,12 +50,12 @@ def test_join_self(idx, join_type): def test_join_multi(): # GH 10665 - midx = pd.MultiIndex.from_product([np.arange(4), np.arange(4)], names=["a", "b"]) + midx = MultiIndex.from_product([np.arange(4), np.arange(4)], names=["a", "b"]) idx = Index([1, 2, 5], name="b") # inner jidx, lidx, ridx = midx.join(idx, how="inner", return_indexers=True) - exp_idx = pd.MultiIndex.from_product([np.arange(4), [1, 2]], names=["a", "b"]) + exp_idx = MultiIndex.from_product([np.arange(4), [1, 2]], names=["a", "b"]) exp_lidx = np.array([1, 2, 5, 6, 9, 10, 13, 14], dtype=np.intp) exp_ridx = np.array([0, 1, 0, 1, 0, 1, 0, 1], dtype=np.intp) tm.assert_index_equal(jidx, exp_idx) @@ -93,8 +92,8 @@ def test_join_multi_wrong_order(): # GH 25760 # GH 28956 - midx1 = pd.MultiIndex.from_product([[1, 2], [3, 4]], names=["a", "b"]) - midx2 = pd.MultiIndex.from_product([[1, 2], [3, 4]], names=["b", "a"]) + midx1 = MultiIndex.from_product([[1, 2], [3, 4]], names=["a", "b"]) + midx2 = MultiIndex.from_product([[1, 2], [3, 4]], names=["b", "a"]) join_idx, lidx, ridx = midx1.join(midx2, return_indexers=True) @@ -108,8 +107,8 @@ def test_join_multi_wrong_order(): def test_join_multi_return_indexers(): # GH 34074 - midx1 = pd.MultiIndex.from_product([[1, 2], [3, 4], [5, 6]], names=["a", "b", "c"]) - midx2 = pd.MultiIndex.from_product([[1, 2], [3, 4]], names=["a", "b"]) + midx1 = MultiIndex.from_product([[1, 2], [3, 4], [5, 6]], names=["a", "b", "c"]) + midx2 = MultiIndex.from_product([[1, 2], [3, 4]], names=["a", "b"]) result = midx1.join(midx2, return_indexers=False) tm.assert_index_equal(result, midx1) diff --git a/pandas/tests/indexes/multi/test_reindex.py b/pandas/tests/indexes/multi/test_reindex.py index ceb14aa82a76c..badaf997e8a35 100644 --- a/pandas/tests/indexes/multi/test_reindex.py +++ b/pandas/tests/indexes/multi/test_reindex.py @@ -49,7 +49,7 @@ def test_reindex_preserves_names_when_target_is_list_or_ndarray(idx): target = idx.copy() idx.names = target.names = [None, None] - other_dtype = pd.MultiIndex.from_product([[1, 2], [3, 4]]) + other_dtype = MultiIndex.from_product([[1, 2], [3, 4]]) # list & ndarray cases assert idx.reindex([])[0].names == [None, None] @@ -70,14 +70,14 @@ def test_reindex_preserves_names_when_target_is_list_or_ndarray(idx): def test_reindex_lvl_preserves_names_when_target_is_list_or_array(): # GH7774 - idx = pd.MultiIndex.from_product([[0, 1], ["a", "b"]], names=["foo", "bar"]) + idx = MultiIndex.from_product([[0, 1], ["a", "b"]], names=["foo", "bar"]) assert idx.reindex([], level=0)[0].names == ["foo", "bar"] assert idx.reindex([], level=1)[0].names == ["foo", "bar"] def test_reindex_lvl_preserves_type_if_target_is_empty_list_or_array(): # GH7774 - idx = pd.MultiIndex.from_product([[0, 1], ["a", "b"]]) + idx = MultiIndex.from_product([[0, 1], ["a", "b"]]) assert idx.reindex([], level=0)[0].levels[0].dtype.type == np.int64 assert idx.reindex([], level=1)[0].levels[1].dtype.type == np.object_ @@ -94,9 +94,9 @@ def test_reindex_base(idx): def test_reindex_non_unique(): - idx = pd.MultiIndex.from_tuples([(0, 0), (1, 1), (1, 1), (2, 2)]) + idx = MultiIndex.from_tuples([(0, 0), (1, 1), (1, 1), (2, 2)]) a = pd.Series(np.arange(4), index=idx) - new_idx = pd.MultiIndex.from_tuples([(0, 0), (1, 1), (2, 2)]) + new_idx = MultiIndex.from_tuples([(0, 0), (1, 1), (2, 2)]) msg = "cannot handle a non-unique multi-index!" with pytest.raises(ValueError, match=msg): diff --git a/pandas/tests/indexes/multi/test_reshape.py b/pandas/tests/indexes/multi/test_reshape.py index 6d8a396119ef3..05691ce4e9f24 100644 --- a/pandas/tests/indexes/multi/test_reshape.py +++ b/pandas/tests/indexes/multi/test_reshape.py @@ -75,12 +75,12 @@ def test_insert(idx): + [("test", 17), ("test", 18)] ) - left = pd.Series(np.linspace(0, 10, 11), pd.MultiIndex.from_tuples(idx[:-2])) + left = pd.Series(np.linspace(0, 10, 11), MultiIndex.from_tuples(idx[:-2])) left.loc[("test", 17)] = 11 left.loc[("test", 18)] = 12 - right = pd.Series(np.linspace(0, 12, 13), pd.MultiIndex.from_tuples(idx)) + right = pd.Series(np.linspace(0, 12, 13), MultiIndex.from_tuples(idx)) tm.assert_series_equal(left, right) diff --git a/pandas/tests/indexes/multi/test_setops.py b/pandas/tests/indexes/multi/test_setops.py index f872315374174..207f178fc2648 100644 --- a/pandas/tests/indexes/multi/test_setops.py +++ b/pandas/tests/indexes/multi/test_setops.py @@ -176,7 +176,7 @@ def test_difference(idx, sort): # name from non-empty array result = first.difference([("foo", "one")], sort=sort) - expected = pd.MultiIndex.from_tuples( + expected = MultiIndex.from_tuples( [("bar", "one"), ("baz", "two"), ("foo", "two"), ("qux", "one"), ("qux", "two")] ) expected.names = first.names @@ -189,7 +189,7 @@ def test_difference(idx, sort): def test_difference_sort_special(): # GH-24959 - idx = pd.MultiIndex.from_product([[1, 0], ["a", "b"]]) + idx = MultiIndex.from_product([[1, 0], ["a", "b"]]) # sort=None, the default result = idx.difference([]) tm.assert_index_equal(result, idx) @@ -198,17 +198,17 @@ def test_difference_sort_special(): @pytest.mark.xfail(reason="Not implemented.") def test_difference_sort_special_true(): # TODO decide on True behaviour - idx = pd.MultiIndex.from_product([[1, 0], ["a", "b"]]) + idx = MultiIndex.from_product([[1, 0], ["a", "b"]]) result = idx.difference([], sort=True) - expected = pd.MultiIndex.from_product([[0, 1], ["a", "b"]]) + expected = MultiIndex.from_product([[0, 1], ["a", "b"]]) tm.assert_index_equal(result, expected) def test_difference_sort_incomparable(): # GH-24959 - idx = pd.MultiIndex.from_product([[1, pd.Timestamp("2000"), 2], ["a", "b"]]) + idx = MultiIndex.from_product([[1, pd.Timestamp("2000"), 2], ["a", "b"]]) - other = pd.MultiIndex.from_product([[3, pd.Timestamp("2000"), 4], ["c", "d"]]) + other = MultiIndex.from_product([[3, pd.Timestamp("2000"), 4], ["c", "d"]]) # sort=None, the default # MultiIndex.difference deviates here from other difference # implementations in not catching the TypeError @@ -222,8 +222,8 @@ def test_difference_sort_incomparable(): def test_difference_sort_incomparable_true(): - idx = pd.MultiIndex.from_product([[1, pd.Timestamp("2000"), 2], ["a", "b"]]) - other = pd.MultiIndex.from_product([[3, pd.Timestamp("2000"), 4], ["c", "d"]]) + idx = MultiIndex.from_product([[1, pd.Timestamp("2000"), 2], ["a", "b"]]) + other = MultiIndex.from_product([[3, pd.Timestamp("2000"), 4], ["c", "d"]]) msg = "The 'sort' keyword only takes the values of None or False; True was passed." with pytest.raises(ValueError, match=msg): @@ -328,7 +328,7 @@ def test_intersection_non_object(idx, sort): def test_intersect_equal_sort(): # GH-24959 - idx = pd.MultiIndex.from_product([[1, 0], ["a", "b"]]) + idx = MultiIndex.from_product([[1, 0], ["a", "b"]]) tm.assert_index_equal(idx.intersection(idx, sort=False), idx) tm.assert_index_equal(idx.intersection(idx, sort=None), idx) @@ -336,15 +336,15 @@ def test_intersect_equal_sort(): @pytest.mark.xfail(reason="Not implemented.") def test_intersect_equal_sort_true(): # TODO decide on True behaviour - idx = pd.MultiIndex.from_product([[1, 0], ["a", "b"]]) - sorted_ = pd.MultiIndex.from_product([[0, 1], ["a", "b"]]) + idx = MultiIndex.from_product([[1, 0], ["a", "b"]]) + sorted_ = MultiIndex.from_product([[0, 1], ["a", "b"]]) tm.assert_index_equal(idx.intersection(idx, sort=True), sorted_) @pytest.mark.parametrize("slice_", [slice(None), slice(0)]) def test_union_sort_other_empty(slice_): # https://github.com/pandas-dev/pandas/issues/24959 - idx = pd.MultiIndex.from_product([[1, 0], ["a", "b"]]) + idx = MultiIndex.from_product([[1, 0], ["a", "b"]]) # default, sort=None other = idx[slice_] @@ -360,16 +360,16 @@ def test_union_sort_other_empty(slice_): def test_union_sort_other_empty_sort(slice_): # TODO decide on True behaviour # # sort=True - idx = pd.MultiIndex.from_product([[1, 0], ["a", "b"]]) + idx = MultiIndex.from_product([[1, 0], ["a", "b"]]) other = idx[:0] result = idx.union(other, sort=True) - expected = pd.MultiIndex.from_product([[0, 1], ["a", "b"]]) + expected = MultiIndex.from_product([[0, 1], ["a", "b"]]) tm.assert_index_equal(result, expected) def test_union_sort_other_incomparable(): # https://github.com/pandas-dev/pandas/issues/24959 - idx = pd.MultiIndex.from_product([[1, pd.Timestamp("2000")], ["a", "b"]]) + idx = MultiIndex.from_product([[1, pd.Timestamp("2000")], ["a", "b"]]) # default, sort=None with tm.assert_produces_warning(RuntimeWarning): @@ -385,14 +385,14 @@ def test_union_sort_other_incomparable(): def test_union_sort_other_incomparable_sort(): # TODO decide on True behaviour # # sort=True - idx = pd.MultiIndex.from_product([[1, pd.Timestamp("2000")], ["a", "b"]]) + idx = MultiIndex.from_product([[1, pd.Timestamp("2000")], ["a", "b"]]) with pytest.raises(TypeError, match="Cannot compare"): idx.union(idx[:1], sort=True) def test_union_non_object_dtype_raises(): # GH#32646 raise NotImplementedError instead of less-informative error - mi = pd.MultiIndex.from_product([["a", "b"], [1, 2]]) + mi = MultiIndex.from_product([["a", "b"], [1, 2]]) idx = mi.levels[1] @@ -414,8 +414,8 @@ def test_union_empty_self_different_names(): "method", ["union", "intersection", "difference", "symmetric_difference"] ) def test_setops_disallow_true(method): - idx1 = pd.MultiIndex.from_product([["a", "b"], [1, 2]]) - idx2 = pd.MultiIndex.from_product([["b", "c"], [1, 2]]) + idx1 = MultiIndex.from_product([["a", "b"], [1, 2]]) + idx2 = MultiIndex.from_product([["b", "c"], [1, 2]]) with pytest.raises(ValueError, match="The 'sort' keyword only takes"): getattr(idx1, method)(idx2, sort=True) @@ -461,8 +461,8 @@ def test_intersect_with_duplicates(tuples, exp_tuples): ) def test_maybe_match_names(data, names, expected): # GH#38323 - mi = pd.MultiIndex.from_tuples([], names=["a", "b"]) - mi2 = pd.MultiIndex.from_tuples([data], names=names) + mi = MultiIndex.from_tuples([], names=["a", "b"]) + mi2 = MultiIndex.from_tuples([data], names=names) result = mi._maybe_match_names(mi2) assert result == expected diff --git a/pandas/tests/indexes/period/test_setops.py b/pandas/tests/indexes/period/test_setops.py index 02c007c394ff5..01bdd79e70ebe 100644 --- a/pandas/tests/indexes/period/test_setops.py +++ b/pandas/tests/indexes/period/test_setops.py @@ -340,7 +340,7 @@ def test_difference_freq(self, sort): def test_intersection_equal_duplicates(self): # GH#38302 - idx = pd.period_range("2011-01-01", periods=2) + idx = period_range("2011-01-01", periods=2) idx_dup = idx.append(idx) result = idx_dup.intersection(idx_dup) tm.assert_index_equal(result, idx) diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 5fd1a15416e23..c02291b151955 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -157,7 +157,7 @@ def test_constructor_from_frame_series_freq(self): dts = ["1-1-1990", "2-1-1990", "3-1-1990", "4-1-1990", "5-1-1990"] expected = DatetimeIndex(dts, freq="MS") - df = pd.DataFrame(np.random.rand(5, 3)) + df = DataFrame(np.random.rand(5, 3)) df["date"] = dts result = DatetimeIndex(df["date"], freq="MS") @@ -378,7 +378,7 @@ def test_constructor_dtypes_datetime(self, tz_naive_fixture, attr, klass): tm.assert_index_equal(result, index) @pytest.mark.parametrize("attr", ["values", "asi8"]) - @pytest.mark.parametrize("klass", [Index, pd.TimedeltaIndex]) + @pytest.mark.parametrize("klass", [Index, TimedeltaIndex]) def test_constructor_dtypes_timedelta(self, attr, klass): index = pd.timedelta_range("1 days", periods=5) index = index._with_freq(None) # wont be preserved by constructors @@ -1507,7 +1507,7 @@ def test_reindex_preserves_type_if_target_is_empty_list_or_array(self, labels): @pytest.mark.parametrize( "labels,dtype", [ - (pd.Int64Index([]), np.int64), + (Int64Index([]), np.int64), (Float64Index([]), np.float64), (DatetimeIndex([]), np.datetime64), ], @@ -1520,7 +1520,7 @@ def test_reindex_doesnt_preserve_type_if_target_is_empty_index(self, labels, dty def test_reindex_no_type_preserve_target_empty_mi(self): index = Index(list("abc")) result = index.reindex( - MultiIndex([pd.Int64Index([]), Float64Index([])], [[], []]) + MultiIndex([Int64Index([]), Float64Index([])], [[], []]) )[0] assert result.levels[0].dtype.type == np.int64 assert result.levels[1].dtype.type == np.float64 @@ -1603,7 +1603,7 @@ async def test_tab_complete_warning(self, ip): def test_contains_method_removed(self, index): # GH#30103 method removed for all types except IntervalIndex - if isinstance(index, pd.IntervalIndex): + if isinstance(index, IntervalIndex): index.contains(1) else: msg = f"'{type(index).__name__}' object has no attribute 'contains'" @@ -1744,12 +1744,12 @@ def test_dropna(self, how, dtype, vals, expected): DatetimeIndex(["2011-01-01", "2011-01-02", "2011-01-03"]), ), ( - pd.TimedeltaIndex(["1 days", "2 days", "3 days"]), - pd.TimedeltaIndex(["1 days", "2 days", "3 days"]), + TimedeltaIndex(["1 days", "2 days", "3 days"]), + TimedeltaIndex(["1 days", "2 days", "3 days"]), ), ( - pd.TimedeltaIndex([pd.NaT, "1 days", "2 days", "3 days", pd.NaT]), - pd.TimedeltaIndex(["1 days", "2 days", "3 days"]), + TimedeltaIndex([pd.NaT, "1 days", "2 days", "3 days", pd.NaT]), + TimedeltaIndex(["1 days", "2 days", "3 days"]), ), ( PeriodIndex(["2012-02", "2012-04", "2012-05"], freq="M"), @@ -1908,13 +1908,13 @@ def test_deprecated_fastpath(): Index(np.array(["a", "b"], dtype=object), name="test", fastpath=True) with pytest.raises(TypeError, match=msg): - pd.Int64Index(np.array([1, 2, 3], dtype="int64"), name="test", fastpath=True) + Int64Index(np.array([1, 2, 3], dtype="int64"), name="test", fastpath=True) with pytest.raises(TypeError, match=msg): RangeIndex(0, 5, 2, name="test", fastpath=True) with pytest.raises(TypeError, match=msg): - pd.CategoricalIndex(["a", "b", "c"], name="test", fastpath=True) + CategoricalIndex(["a", "b", "c"], name="test", fastpath=True) def test_shape_of_invalid_index(): @@ -1941,12 +1941,12 @@ def test_validate_1d_input(): Float64Index(arr.astype(np.float64)) with pytest.raises(ValueError, match=msg): - pd.Int64Index(arr.astype(np.int64)) + Int64Index(arr.astype(np.int64)) with pytest.raises(ValueError, match=msg): - pd.UInt64Index(arr.astype(np.uint64)) + UInt64Index(arr.astype(np.uint64)) - df = pd.DataFrame(arr.reshape(4, 2)) + df = DataFrame(arr.reshape(4, 2)) with pytest.raises(ValueError, match=msg): Index(df)