Skip to content

Commit d1d75d7

Browse files
committed
Revert "BUG: downcast='unsigned' on 0 would would not downcast to unsigned."
This reverts commit 6ff53c2.
1 parent f99f050 commit d1d75d7

File tree

3 files changed

+1
-48
lines changed

3 files changed

+1
-48
lines changed

doc/source/whatsnew/v0.19.1.txt

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ Bug Fixes
6161

6262
- Bug in ``Timestamp`` where dates very near the minimum (1677-09) could underflow on creation (:issue:`14415`)
6363

64-
- Bug in ``pd.to_numeric`` where 0 was not included when ``downcast='unsigned'`` is passed (:issue:`14401`)
6564
- Bug in ``pd.concat`` where names of the ``keys`` were not propagated to the resulting ``MultiIndex`` (:issue:`14252`)
6665
- Bug in ``pd.concat`` where ``axis`` cannot take string parameters ``'rows'`` or ``'columns'`` (:issue:`14369`)
6766
- Bug in ``pd.concat`` with dataframes heterogeneous in length and tuple ``keys`` (:issue:`14438`)

pandas/tools/tests/test_util.py

-46
Original file line numberDiff line numberDiff line change
@@ -401,52 +401,6 @@ def test_downcast(self):
401401
res = pd.to_numeric(data, downcast=downcast)
402402
tm.assert_numpy_array_equal(res, expected)
403403

404-
def test_downcast_limits(self):
405-
# Test the limits of each downcast. #14401
406-
# uint64 is not fully supported ATM
407-
dtype_downcast_min_max = [
408-
('int8', 'integer',
409-
[np.iinfo(np.int8).min, np.iinfo(np.int8).max]),
410-
('int16', 'integer',
411-
[np.iinfo(np.int16).min, np.iinfo(np.int16).max]),
412-
('int32', 'integer',
413-
[np.iinfo(np.int32).min, np.iinfo(np.int32).max]),
414-
('int64', 'integer',
415-
[np.iinfo(np.int64).min, np.iinfo(np.int64).max]),
416-
('uint8', 'unsigned',
417-
[np.iinfo(np.uint8).min, np.iinfo(np.uint8).max]),
418-
('uint16', 'unsigned',
419-
[np.iinfo(np.uint16).min, np.iinfo(np.uint16).max]),
420-
('uint32', 'unsigned',
421-
[np.iinfo(np.uint32).min, np.iinfo(np.uint32).max]),
422-
# ('uint64', 'unsigned',
423-
# [np.iinfo(np.uint64).min, np.iinfo(np.uint64).max]),
424-
425-
('int16', 'integer',
426-
[np.iinfo(np.int8).min, np.iinfo(np.int8).max + 1]),
427-
('int32', 'integer',
428-
[np.iinfo(np.int16).min, np.iinfo(np.int16).max + 1]),
429-
('int64', 'integer',
430-
[np.iinfo(np.int32).min, np.iinfo(np.int32).max + 1]),
431-
('int16', 'integer',
432-
[np.iinfo(np.int8).min - 1, np.iinfo(np.int16).max]),
433-
('int32', 'integer',
434-
[np.iinfo(np.int16).min - 1, np.iinfo(np.int32).max]),
435-
('int64', 'integer',
436-
[np.iinfo(np.int32).min - 1, np.iinfo(np.int64).max]),
437-
('uint16', 'unsigned',
438-
[np.iinfo(np.uint8).min, np.iinfo(np.uint8).max + 1]),
439-
('uint32', 'unsigned',
440-
[np.iinfo(np.uint16).min, np.iinfo(np.uint16).max + 1]),
441-
# ('uint64', 'unsigned',
442-
# [np.iinfo(np.uint32).min, np.iinfo(np.uint32).max + 1]),
443-
]
444-
445-
for dtype, downcast, min_max in dtype_downcast_min_max:
446-
series = pd.to_numeric(pd.Series(min_max), downcast=downcast)
447-
tm.assert_equal(series.dtype, dtype)
448-
449-
450404
if __name__ == '__main__':
451405
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
452406
exit=False)

pandas/tools/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def to_numeric(arg, errors='raise', downcast=None):
205205

206206
if downcast in ('integer', 'signed'):
207207
typecodes = np.typecodes['Integer']
208-
elif downcast == 'unsigned' and np.min(values) >= 0:
208+
elif downcast == 'unsigned' and np.min(values) > 0:
209209
typecodes = np.typecodes['UnsignedInteger']
210210
elif downcast == 'float':
211211
typecodes = np.typecodes['Float']

0 commit comments

Comments
 (0)