Skip to content

Commit 7279c1e

Browse files
committed
fix comments
1 parent c94dc15 commit 7279c1e

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

pandas/core/indexes/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,12 +2416,13 @@ def _is_multi(self) -> bool:
24162416
"""
24172417
return isinstance(self, ABCMultiIndex)
24182418

2419+
@final
24192420
@classmethod
24202421
def _is_num_index(cls) -> bool:
24212422
"""
2422-
Whether self is a NumIndex, but not *not* Int64Index, UInt64Index, FloatIndex.
2423+
Check if this is a NumericIndex, but *not* Int64Index, UInt64Index, FloatIndex.
24232424
2424-
Typically used to check if an operation should return NumIndex or plain Index.
2425+
Used to check if an operation should return NumericIndex or plain Index.
24252426
"""
24262427
from pandas.core.indexes.numeric import (
24272428
Float64Index,

pandas/core/indexes/category.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,21 +293,21 @@ def astype(self, dtype, copy: bool = True) -> Index:
293293

294294
dtype = pandas_dtype(dtype)
295295

296-
cat = self.categories
296+
categories = self.categories
297297
# the super method always returns Int64Index, UInt64Index and Float64Index
298298
# but if e.g. the categories are a NumIndex with dtype float32, we want to
299299
# return an index with the same dtype as self.categories.
300-
if cat._is_num_index():
301-
assert isinstance(cat, NumericIndex) # mypy complaint fix
300+
if categories._is_num_index():
301+
assert isinstance(categories, NumericIndex) # mypy complaint fix
302302
try:
303-
cat._validate_dtype(dtype)
303+
categories._validate_dtype(dtype)
304304
except ValueError:
305305
pass
306306
else:
307307
new_values = self._data.astype(dtype, copy=copy)
308308
# pass copy=False because any copying has been done in the
309309
# _data.astype call above
310-
return type(cat)(new_values, name=self.name, copy=False)
310+
return type(categories)(new_values, name=self.name, copy=False)
311311

312312
return super().astype(dtype, copy=copy)
313313

pandas/core/indexes/numeric.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from pandas._typing import (
1616
Dtype,
1717
DtypeObj,
18+
final,
1819
)
1920
from pandas.util._decorators import (
2021
cache_readonly,
@@ -268,6 +269,15 @@ def _assert_safe_casting(cls, data, subarr):
268269
"""
269270
pass
270271

272+
@final
273+
@cache_readonly
274+
def _can_hold_na(self) -> bool:
275+
if is_integer_dtype(self.dtype):
276+
return False
277+
else:
278+
return True
279+
280+
@final
271281
@property
272282
def _is_all_dates(self) -> bool:
273283
"""

0 commit comments

Comments
 (0)