Skip to content

Commit 0762577

Browse files
Terji PetersenTerji Petersen
Terji Petersen
authored and
Terji Petersen
committed
DEPR: don't make Index instantiate Int64/Uint64/Flaot64Index
1 parent 4c5db2e commit 0762577

File tree

91 files changed

+656
-445
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+656
-445
lines changed

pandas/core/arrays/datetimes.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ def isocalendar(self) -> DataFrame:
13821382
0 2000
13831383
1 2001
13841384
2 2002
1385-
dtype: int64
1385+
dtype: int32
13861386
""",
13871387
)
13881388
month = _field_accessor(
@@ -1405,7 +1405,7 @@ def isocalendar(self) -> DataFrame:
14051405
0 1
14061406
1 2
14071407
2 3
1408-
dtype: int64
1408+
dtype: int32
14091409
""",
14101410
)
14111411
day = _field_accessor(
@@ -1428,7 +1428,7 @@ def isocalendar(self) -> DataFrame:
14281428
0 1
14291429
1 2
14301430
2 3
1431-
dtype: int64
1431+
dtype: int32
14321432
""",
14331433
)
14341434
hour = _field_accessor(
@@ -1451,7 +1451,7 @@ def isocalendar(self) -> DataFrame:
14511451
0 0
14521452
1 1
14531453
2 2
1454-
dtype: int64
1454+
dtype: int32
14551455
""",
14561456
)
14571457
minute = _field_accessor(
@@ -1474,7 +1474,7 @@ def isocalendar(self) -> DataFrame:
14741474
0 0
14751475
1 1
14761476
2 2
1477-
dtype: int64
1477+
dtype: int32
14781478
""",
14791479
)
14801480
second = _field_accessor(
@@ -1497,7 +1497,7 @@ def isocalendar(self) -> DataFrame:
14971497
0 0
14981498
1 1
14991499
2 2
1500-
dtype: int64
1500+
dtype: int32
15011501
""",
15021502
)
15031503
microsecond = _field_accessor(
@@ -1520,7 +1520,7 @@ def isocalendar(self) -> DataFrame:
15201520
0 0
15211521
1 1
15221522
2 2
1523-
dtype: int64
1523+
dtype: int32
15241524
""",
15251525
)
15261526
nanosecond = _field_accessor(
@@ -1543,7 +1543,7 @@ def isocalendar(self) -> DataFrame:
15431543
0 0
15441544
1 1
15451545
2 2
1546-
dtype: int64
1546+
dtype: int32
15471547
""",
15481548
)
15491549
_dayofweek_doc = """
@@ -1578,7 +1578,7 @@ def isocalendar(self) -> DataFrame:
15781578
2017-01-06 4
15791579
2017-01-07 5
15801580
2017-01-08 6
1581-
Freq: D, dtype: int64
1581+
Freq: D, dtype: int32
15821582
"""
15831583
day_of_week = _field_accessor("day_of_week", "dow", _dayofweek_doc)
15841584
dayofweek = day_of_week

pandas/core/arrays/interval.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
from pandas.errors import IntCastingNaNError
4646
from pandas.util._decorators import Appender
4747

48-
from pandas.core.dtypes.cast import LossySetitemError
48+
from pandas.core.dtypes.cast import (
49+
LossySetitemError,
50+
construct_1d_object_array_from_listlike,
51+
)
4952
from pandas.core.dtypes.common import (
5053
is_categorical_dtype,
5154
is_dtype_equal,
@@ -1750,5 +1753,6 @@ def _maybe_convert_platform_interval(values) -> ArrayLike:
17501753
values = extract_array(values, extract_numpy=True)
17511754

17521755
if not hasattr(values, "dtype"):
1753-
return np.asarray(values)
1756+
values = construct_1d_object_array_from_listlike(values)
1757+
return lib.maybe_convert_objects(values)
17541758
return values

pandas/core/arrays/timedeltas.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ def total_seconds(self) -> npt.NDArray[np.float64]:
812812
dtype='timedelta64[ns]', freq=None)
813813
814814
>>> idx.total_seconds()
815-
Float64Index([0.0, 86400.0, 172800.0, 259200.0, 345600.0],
815+
NumericIndex([0.0, 86400.0, 172800.0, 259200.0, 345600.0],
816816
dtype='float64')
817817
"""
818818
pps = periods_per_second(self._creso)

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6084,7 +6084,7 @@ def astype(
60846084
0 1
60856085
1 2
60866086
dtype: category
6087-
Categories (2, int64): [1, 2]
6087+
Categories (2, int32): [1, 2]
60886088
60896089
Convert to ordered categorical type with custom ordering:
60906090

pandas/core/indexes/accessors.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class DatetimeProperties(Properties):
161161
0 0
162162
1 1
163163
2 2
164-
dtype: int64
164+
dtype: int32
165165
166166
>>> hours_series = pd.Series(pd.date_range("2000-01-01", periods=3, freq="h"))
167167
>>> hours_series
@@ -173,7 +173,7 @@ class DatetimeProperties(Properties):
173173
0 0
174174
1 1
175175
2 2
176-
dtype: int64
176+
dtype: int32
177177
178178
>>> quarters_series = pd.Series(pd.date_range("2000-01-01", periods=3, freq="q"))
179179
>>> quarters_series
@@ -185,7 +185,7 @@ class DatetimeProperties(Properties):
185185
0 1
186186
1 2
187187
2 3
188-
dtype: int64
188+
dtype: int32
189189
190190
Returns a Series indexed like the original Series.
191191
Raises TypeError if the Series does not contain datetimelike values.
@@ -303,7 +303,7 @@ class TimedeltaProperties(Properties):
303303
0 1
304304
1 2
305305
2 3
306-
dtype: int64
306+
dtype: int32
307307
"""
308308

309309
def to_pytimedelta(self) -> np.ndarray:

0 commit comments

Comments
 (0)