Skip to content

Commit 9494274

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

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

pandas/tests/frame/methods/test_astype.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
CategoricalDtype,
1212
DataFrame,
1313
DatetimeTZDtype,
14+
Index,
1415
Interval,
1516
IntervalDtype,
1617
NaT,
@@ -22,7 +23,6 @@
2223
option_context,
2324
)
2425
import pandas._testing as tm
25-
from pandas.core.api import UInt64Index
2626

2727

2828
def _check_cast(df, v):
@@ -372,7 +372,7 @@ def test_astype_extension_dtypes_duplicate_col(self, dtype):
372372
)
373373
def test_astype_column_metadata(self, dtype):
374374
# GH#19920
375-
columns = UInt64Index([100, 200, 300], name="foo")
375+
columns = Index([100, 200, 300], dtype=np.uint64, name="foo")
376376
df = DataFrame(np.arange(15).reshape(5, 3), columns=columns)
377377
df = df.astype(dtype)
378378
tm.assert_index_equal(df.columns, columns)
@@ -441,7 +441,7 @@ def test_astype_to_datetime_unit(self, unit):
441441
arr = np.array([[1, 2, 3]], dtype=dtype)
442442
df = DataFrame(arr)
443443
ser = df.iloc[:, 0]
444-
idx = pd.Index(ser)
444+
idx = Index(ser)
445445
dta = ser._values
446446

447447
if unit in ["ns", "us", "ms", "s"]:
@@ -476,7 +476,7 @@ def test_astype_to_datetime_unit(self, unit):
476476
exp_dta = exp_ser._values
477477

478478
res_index = idx.astype(dtype)
479-
exp_index = pd.Index(exp_ser)
479+
exp_index = Index(exp_ser)
480480
assert exp_index.dtype == dtype
481481
tm.assert_index_equal(res_index, exp_index)
482482

@@ -504,7 +504,7 @@ def test_astype_to_timedelta_unit(self, unit):
504504
arr = np.array([[1, 2, 3]], dtype=dtype)
505505
df = DataFrame(arr)
506506
ser = df.iloc[:, 0]
507-
tdi = pd.Index(ser)
507+
tdi = Index(ser)
508508
tda = tdi._values
509509

510510
if unit in ["us", "ms", "s"]:

pandas/tests/frame/methods/test_truncate.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
from pandas import (
66
DataFrame,
77
DatetimeIndex,
8+
Index,
89
Series,
910
date_range,
1011
)
1112
import pandas._testing as tm
12-
from pandas.core.api import Int64Index
1313

1414

1515
class TestDataFrameTruncate:
@@ -114,13 +114,13 @@ def test_truncate_nonsortedindex_axis1(self):
114114
"before, after, indices",
115115
[(1, 2, [2, 1]), (None, 2, [2, 1, 0]), (1, None, [3, 2, 1])],
116116
)
117-
@pytest.mark.parametrize("klass", [Int64Index, DatetimeIndex])
117+
@pytest.mark.parametrize("dtyp", [*tm.ALL_REAL_NUMPY_DTYPES, "datetime64[ns]"])
118118
def test_truncate_decreasing_index(
119-
self, before, after, indices, klass, frame_or_series
119+
self, before, after, indices, dtyp, frame_or_series
120120
):
121121
# https://github.com/pandas-dev/pandas/issues/33756
122-
idx = klass([3, 2, 1, 0])
123-
if klass is DatetimeIndex:
122+
idx = Index([3, 2, 1, 0], dtype=dtyp)
123+
if isinstance(idx, DatetimeIndex):
124124
before = pd.Timestamp(before) if before is not None else None
125125
after = pd.Timestamp(after) if after is not None else None
126126
indices = [pd.Timestamp(i) for i in indices]

0 commit comments

Comments
 (0)