Skip to content

Commit 388604a

Browse files
committed
BUG: fixed platform int issues on 32-bit
1 parent 4090a85 commit 388604a

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

pandas/core/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,13 +1612,13 @@ def _astype_nansafe(arr, dtype, copy = True):
16121612
if is_datetime64_dtype(arr):
16131613
if dtype == object:
16141614
return tslib.ints_to_pydatetime(arr.view(np.int64))
1615-
elif issubclass(dtype.type, np.int):
1615+
elif dtype == np.int64:
16161616
return arr.view(dtype)
16171617
elif dtype != _NS_DTYPE:
16181618
raise TypeError("cannot astype a datetimelike from [%s] to [%s]" % (arr.dtype,dtype))
16191619
return arr.astype(_NS_DTYPE)
16201620
elif is_timedelta64_dtype(arr):
1621-
if issubclass(dtype.type, np.int):
1621+
if dtype == np.int64:
16221622
return arr.view(dtype)
16231623
elif dtype == object:
16241624
return arr.astype(object)

pandas/core/indexing.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ def _convert_for_reindex(self, key, axis=0):
322322
keyarr = _asarray_tuplesafe(key)
323323

324324
if _is_integer_dtype(keyarr) and not _is_integer_index(labels):
325+
keyarr = com._ensure_platform_int(keyarr)
325326
return labels.take(keyarr)
326327

327328
return keyarr
@@ -466,10 +467,11 @@ def _reindex(keys, level=None):
466467
if len(missing):
467468
l = np.arange(len(indexer))
468469

470+
missing = com._ensure_platform_int(missing)
469471
missing_labels = keyarr.take(missing)
470-
missing_labels_indexer = l[~check]
472+
missing_labels_indexer = com._ensure_int64(l[~check])
471473
cur_labels = result._get_axis(axis).values
472-
cur_labels_indexer = l[check]
474+
cur_labels_indexer = com._ensure_int64(l[check])
473475
new_labels = lib.combine_from_indexers(cur_labels, cur_labels_indexer,
474476
missing_labels, missing_labels_indexer)
475477
result = result.reindex_axis(new_labels,axis=axis)

pandas/tests/test_series.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1878,10 +1878,11 @@ def test_constructor_dtype_timedelta64(self):
18781878
self.assertRaises(TypeError, td.astype, 'm8[%s]' % t)
18791879

18801880
# valid astype
1881-
td.astype('int')
1881+
td.astype('int64')
18821882

18831883
# this is an invalid casting
18841884
self.assertRaises(Exception, Series, [ timedelta(days=i) for i in range(3) ] + [ 'foo' ], dtype='m8[ns]' )
1885+
self.assertRaises(TypeError, td.astype, 'int32')
18851886

18861887
# leave as object here
18871888
td = Series([ timedelta(days=i) for i in range(3) ] + [ 'foo' ])

0 commit comments

Comments
 (0)