@@ -391,14 +391,6 @@ def test_downcast(self):
391
391
res = pd .to_numeric (data , downcast = downcast )
392
392
tm .assert_numpy_array_equal (res , expected )
393
393
394
- #check that 0 works as a unsigned downcast
395
-
396
- data = [0 , 1 , 2 , 3 ]
397
- res = pd .to_numeric (data , downcast = downcast )
398
- expected = np .array (data , dtype = np .uint8 )
399
- tm .assert_numpy_array_equal (res , expected )
400
-
401
-
402
394
# the smallest integer dtype need not be np.(u)int8
403
395
data = ['256' , 257 , 258 ]
404
396
@@ -409,6 +401,32 @@ def test_downcast(self):
409
401
res = pd .to_numeric (data , downcast = downcast )
410
402
tm .assert_numpy_array_equal (res , expected )
411
403
404
+ # check that the smallest and largest values in each integer type pass to each type.
405
+ int8 = [- 128 , 127 ]
406
+ int8_Series = pd .to_numeric (int8 , downcast = 'integer' )
407
+ tm .assert_equal (int8_Series .dtype , 'int8' )
408
+ int16 = [- 32768 , 32767 ]
409
+ int16_Series = pd .to_numeric (int16 , downcast = 'integer' )
410
+ tm .assert_equal (int16_Series .dtype , 'int16' )
411
+ int32 = [- 2147483648 , 2147483647 ]
412
+ int32_Series = pd .to_numeric (int32 , downcast = 'integer' )
413
+ tm .assert_equal (int32_Series .dtype , 'int32' )
414
+ int64 = [- 9223372036854775808 , 9223372036854775807 ]
415
+ int64_Series = pd .to_numeric (int64 , downcast = 'integer' )
416
+ tm .assert_equal (int64_Series .dtype , 'int64' )
417
+ uint8 = [0 , 255 ]
418
+ uint8_Series = pd .to_numeric (uint8 , downcast = 'unsigned' )
419
+ tm .assert_equal (uint8_Series .dtype , 'uint8' )
420
+ uint16 = [0 , 65535 ]
421
+ uint16_Series = pd .to_numeric (uint16 , downcast = 'unsigned' )
422
+ tm .assert_equal (uint16_Series .dtype , 'uint16' )
423
+ uint32 = [0 , 4294967295 ]
424
+ uint32_Series = pd .to_numeric (uint32 , downcast = 'unsigned' )
425
+ tm .assert_equal (uint32_Series .dtype , 'uint32' )
426
+ # uint64 = [0, 18446744073709551615]
427
+ # uint64_Series = pd.to_numeric(uint64, downcast = 'unsigned')
428
+ # tm.assert_equal(uint64_Series.dtype, 'uint64')
429
+
412
430
if __name__ == '__main__' :
413
431
nose .runmodule (argv = [__file__ , '-vvs' , '-x' , '--pdb' , '--pdb-failure' ],
414
432
exit = False )
0 commit comments