|
96 | 96 | is_period_dtype,
|
97 | 97 | is_string_dtype,
|
98 | 98 | is_timedelta64_dtype,
|
99 |
| - is_unsigned_integer_dtype, |
100 | 99 | pandas_dtype,
|
101 | 100 | )
|
102 | 101 | from pandas.core.dtypes.dtypes import (
|
@@ -468,39 +467,10 @@ def astype(self, dtype, copy: bool = True):
|
468 | 467 | # we deliberately ignore int32 vs. int64 here.
|
469 | 468 | # See https://github.com/pandas-dev/pandas/issues/24381 for more.
|
470 | 469 | values = self.asi8
|
471 |
| - |
472 |
| - if is_unsigned_integer_dtype(dtype): |
473 |
| - # Again, we ignore int32 vs. int64 |
474 |
| - values = values.view("uint64") |
475 |
| - if dtype != np.uint64: |
476 |
| - # GH#45034 |
477 |
| - warnings.warn( |
478 |
| - f"The behavior of .astype from {self.dtype} to {dtype} is " |
479 |
| - "deprecated. In a future version, this astype will return " |
480 |
| - "exactly the specified dtype instead of uint64, and will " |
481 |
| - "raise if that conversion overflows.", |
482 |
| - FutureWarning, |
483 |
| - stacklevel=find_stack_level(), |
484 |
| - ) |
485 |
| - elif (self.asi8 < 0).any(): |
486 |
| - # GH#45034 |
487 |
| - warnings.warn( |
488 |
| - f"The behavior of .astype from {self.dtype} to {dtype} is " |
489 |
| - "deprecated. In a future version, this astype will " |
490 |
| - "raise if the conversion overflows, as it did in this " |
491 |
| - "case with negative int64 values.", |
492 |
| - FutureWarning, |
493 |
| - stacklevel=find_stack_level(), |
494 |
| - ) |
495 |
| - elif dtype != np.int64: |
496 |
| - # GH#45034 |
497 |
| - warnings.warn( |
498 |
| - f"The behavior of .astype from {self.dtype} to {dtype} is " |
499 |
| - "deprecated. In a future version, this astype will return " |
500 |
| - "exactly the specified dtype instead of int64, and will " |
501 |
| - "raise if that conversion overflows.", |
502 |
| - FutureWarning, |
503 |
| - stacklevel=find_stack_level(), |
| 470 | + if dtype != np.int64: |
| 471 | + raise TypeError( |
| 472 | + f"Converting from {self.dtype} to {dtype} is not supported. " |
| 473 | + "Do obj.astype('int64').astype(dtype) instead" |
504 | 474 | )
|
505 | 475 |
|
506 | 476 | if copy:
|
|
0 commit comments