Skip to content

Commit 33bb44f

Browse files
committed
fix more errors
1 parent 7afc611 commit 33bb44f

File tree

8 files changed

+46
-26
lines changed

8 files changed

+46
-26
lines changed

pandas/tests/arithmetic/test_numeric.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@
1414

1515
import pandas as pd
1616
from pandas import (
17-
Float64Index,
1817
Index,
19-
Int64Index,
2018
RangeIndex,
2119
Series,
2220
Timedelta,
2321
TimedeltaIndex,
24-
UInt64Index,
2522
array,
2623
)
2724
import pandas._testing as tm
2825
from pandas.core import ops
26+
from pandas.core.api import (
27+
Float64Index,
28+
Int64Index,
29+
UInt64Index,
30+
)
2931
from pandas.core.computation import expressions as expr
3032

3133

pandas/tests/arithmetic/test_timedelta64.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
timedelta_range,
2727
)
2828
import pandas._testing as tm
29+
from pandas.core.api import (
30+
Float64Index,
31+
Int64Index,
32+
UInt64Index,
33+
)
2934
from pandas.tests.arithmetic.common import (
3035
assert_invalid_addsub_type,
3136
assert_invalid_comparison,
@@ -489,10 +494,10 @@ def test_addition_ops(self):
489494
# random indexes
490495
msg = "Addition/subtraction of integers and integer-arrays"
491496
with pytest.raises(TypeError, match=msg):
492-
tdi + pd.Int64Index([1, 2, 3])
497+
tdi + Int64Index([1, 2, 3])
493498

494499
# this is a union!
495-
# pytest.raises(TypeError, lambda : pd.Int64Index([1,2,3]) + tdi)
500+
# pytest.raises(TypeError, lambda : Int64Index([1,2,3]) + tdi)
496501

497502
result = tdi + dti # name will be reset
498503
expected = DatetimeIndex(["20130102", NaT, "20130105"])
@@ -1570,9 +1575,9 @@ def test_tdi_mul_float_series(self, box_with_array):
15701575
"other",
15711576
[
15721577
np.arange(1, 11),
1573-
pd.Int64Index(range(1, 11)),
1574-
pd.UInt64Index(range(1, 11)),
1575-
pd.Float64Index(range(1, 11)),
1578+
Int64Index(range(1, 11)),
1579+
UInt64Index(range(1, 11)),
1580+
Float64Index(range(1, 11)),
15761581
pd.RangeIndex(1, 11),
15771582
],
15781583
ids=lambda x: type(x).__name__,
@@ -1642,7 +1647,7 @@ def test_td64arr_div_tdlike_scalar(self, two_hours, box_with_array):
16421647
xbox = np.ndarray if box is pd.array else box
16431648

16441649
rng = timedelta_range("1 days", "10 days", name="foo")
1645-
expected = pd.Float64Index((np.arange(10) + 1) * 12, name="foo")
1650+
expected = Float64Index((np.arange(10) + 1) * 12, name="foo")
16461651

16471652
rng = tm.box_expected(rng, box)
16481653
expected = tm.box_expected(expected, xbox)
@@ -1685,7 +1690,7 @@ def test_td64arr_div_tdlike_scalar_with_nat(self, two_hours, box_with_array):
16851690
xbox = np.ndarray if box is pd.array else box
16861691

16871692
rng = TimedeltaIndex(["1 days", NaT, "2 days"], name="foo")
1688-
expected = pd.Float64Index([12, np.nan, 24], name="foo")
1693+
expected = Float64Index([12, np.nan, 24], name="foo")
16891694

16901695
rng = tm.box_expected(rng, box)
16911696
expected = tm.box_expected(expected, xbox)
@@ -1703,7 +1708,7 @@ def test_td64arr_div_td64_ndarray(self, box_with_array):
17031708
xbox = np.ndarray if box is pd.array else box
17041709

17051710
rng = TimedeltaIndex(["1 days", NaT, "2 days"])
1706-
expected = pd.Float64Index([12, np.nan, 24])
1711+
expected = Float64Index([12, np.nan, 24])
17071712

17081713
rng = tm.box_expected(rng, box)
17091714
expected = tm.box_expected(expected, xbox)
@@ -1846,7 +1851,7 @@ def test_td64arr_floordiv_tdlike_scalar(self, two_hours, box_with_array):
18461851
xbox = np.ndarray if box is pd.array else box
18471852

18481853
tdi = timedelta_range("1 days", "10 days", name="foo")
1849-
expected = pd.Int64Index((np.arange(10) + 1) * 12, name="foo")
1854+
expected = Int64Index((np.arange(10) + 1) * 12, name="foo")
18501855

18511856
tdi = tm.box_expected(tdi, box)
18521857
expected = tm.box_expected(expected, xbox)

pandas/tests/arrays/categorical/test_constructors.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
timedelta_range,
3535
)
3636
import pandas._testing as tm
37+
from pandas.core.api import Int64Index
3738

3839

3940
class TestCategoricalConstructors:
@@ -71,7 +72,7 @@ def test_constructor_empty(self):
7172
tm.assert_index_equal(c.categories, expected)
7273

7374
c = Categorical([], categories=[1, 2, 3])
74-
expected = pd.Int64Index([1, 2, 3])
75+
expected = Int64Index([1, 2, 3])
7576
tm.assert_index_equal(c.categories, expected)
7677

7778
def test_constructor_empty_boolean(self):

pandas/tests/arrays/sparse/test_array.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pandas as pd
1212
from pandas import isna
1313
import pandas._testing as tm
14+
from pandas.core.api import Int64Index
1415
from pandas.core.arrays.sparse import (
1516
SparseArray,
1617
SparseDtype,
@@ -1309,7 +1310,7 @@ def test_dropna(fill_value):
13091310
tm.assert_sp_array_equal(arr.dropna(), exp)
13101311

13111312
df = pd.DataFrame({"a": [0, 1], "b": arr})
1312-
expected_df = pd.DataFrame({"a": [1], "b": exp}, index=pd.Int64Index([1]))
1313+
expected_df = pd.DataFrame({"a": [1], "b": exp}, index=Int64Index([1]))
13131314
tm.assert_equal(df.dropna(), expected_df)
13141315

13151316

pandas/tests/dtypes/test_generic.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
import pandas as pd
99
import pandas._testing as tm
10+
from pandas.core.api import (
11+
Float64Index,
12+
Int64Index,
13+
UInt64Index,
14+
)
1015

1116

1217
class TestABCClasses:
@@ -23,9 +28,9 @@ class TestABCClasses:
2328
timedelta_array = pd.core.arrays.TimedeltaArray(timedelta_index)
2429

2530
abc_pairs = [
26-
("ABCInt64Index", pd.Int64Index([1, 2, 3])),
27-
("ABCUInt64Index", pd.UInt64Index([1, 2, 3])),
28-
("ABCFloat64Index", pd.Float64Index([1, 2, 3])),
31+
("ABCInt64Index", Int64Index([1, 2, 3])),
32+
("ABCUInt64Index", UInt64Index([1, 2, 3])),
33+
("ABCFloat64Index", Float64Index([1, 2, 3])),
2934
("ABCMultiIndex", multi_index),
3035
("ABCDatetimeIndex", datetime_index),
3136
("ABCRangeIndex", pd.RangeIndex(3)),

pandas/tests/dtypes/test_missing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
import pandas as pd
3636
from pandas import (
3737
DatetimeIndex,
38-
Float64Index,
3938
NaT,
4039
Series,
4140
TimedeltaIndex,
4241
date_range,
4342
)
4443
import pandas._testing as tm
44+
from pandas.core.api import Float64Index
4545

4646
now = pd.Timestamp.now()
4747
utcnow = pd.Timestamp.now("UTC")

pandas/tests/series/indexing/test_get.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pandas as pd
55
from pandas import Series
66
import pandas._testing as tm
7+
from pandas.core.api import Float64Index
78

89

910
def test_get():
@@ -64,7 +65,7 @@ def test_get():
6465
54,
6566
]
6667
),
67-
index=pd.Float64Index(
68+
index=Float64Index(
6869
[
6970
25.0,
7071
36.0,
@@ -111,7 +112,7 @@ def test_get():
111112

112113
def test_get_nan():
113114
# GH 8569
114-
s = pd.Float64Index(range(10)).to_series()
115+
s = Float64Index(range(10)).to_series()
115116
assert s.get(np.nan) is None
116117
assert s.get(np.nan, default="Missing") == "Missing"
117118

@@ -120,7 +121,7 @@ def test_get_nan_multiple():
120121
# GH 8569
121122
# ensure that fixing "test_get_nan" above hasn't broken get
122123
# with multiple elements
123-
s = pd.Float64Index(range(10)).to_series()
124+
s = Float64Index(range(10)).to_series()
124125

125126
idx = [2, 30]
126127
assert s.get(idx) is None

pandas/tseries/frequencies.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,12 @@ def infer_freq(index, warn: bool = True) -> str | None:
153153
>>> pd.infer_freq(idx)
154154
'D'
155155
"""
156-
import pandas as pd
156+
from pandas.core.api import (
157+
DatetimeIndex,
158+
Float64Index,
159+
Index,
160+
Int64Index,
161+
)
157162

158163
if isinstance(index, ABCSeries):
159164
values = index._values
@@ -182,15 +187,15 @@ def infer_freq(index, warn: bool = True) -> str | None:
182187
inferer = _TimedeltaFrequencyInferer(index, warn=warn)
183188
return inferer.get_freq()
184189

185-
if isinstance(index, pd.Index) and not isinstance(index, pd.DatetimeIndex):
186-
if isinstance(index, (pd.Int64Index, pd.Float64Index)):
190+
if isinstance(index, Index) and not isinstance(index, DatetimeIndex):
191+
if isinstance(index, (Int64Index, Float64Index)):
187192
raise TypeError(
188193
f"cannot infer freq from a non-convertible index type {type(index)}"
189194
)
190195
index = index._values
191196

192-
if not isinstance(index, pd.DatetimeIndex):
193-
index = pd.DatetimeIndex(index)
197+
if not isinstance(index, DatetimeIndex):
198+
index = DatetimeIndex(index)
194199

195200
inferer = _FrequencyInferer(index, warn=warn)
196201
return inferer.get_freq()

0 commit comments

Comments
 (0)