Implement UInt64 handling, tests, and docs · pandas-dev/pandas@3fca810 (original) (raw)

Original file line number Diff line number Diff line change
@@ -21,7 +21,8 @@
21 21 is_datetime64_dtype, is_datetime64tz_dtype, is_datetime_or_timedelta_dtype,
22 22 is_dtype_equal, is_extension_array_dtype, is_float_dtype, is_integer_dtype,
23 23 is_list_like, is_object_dtype, is_offsetlike, is_period_dtype,
24 -is_string_dtype, is_timedelta64_dtype, needs_i8_conversion, pandas_dtype)
24 +is_string_dtype, is_timedelta64_dtype, is_unsigned_integer_dtype,
25 +needs_i8_conversion, pandas_dtype)
25 26 from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries
26 27 from pandas.core.dtypes.missing import isna
27 28
@@ -419,6 +420,11 @@ def astype(self, dtype, copy=True):
419 420 # we deliberately ignore int32 vs. int64 here.
420 421 # See https://github.com/pandas-dev/pandas/issues/24381 for more.
421 422 values = self.asi8
423 +
424 +if is_unsigned_integer_dtype(dtype):
425 +# Again, we ignore int32 vs. int64
426 +values = values.view("uint64")
427 +
422 428 if copy:
423 429 values = values.copy()
424 430 return values