Skip to content

Commit c4f74cb

Browse files
committed
move int8/16/32 type conversions to index_class_helper.pxi.in
1 parent e465749 commit c4f74cb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pandas/_libs/index.pyx

-2
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,6 @@ cdef class IndexEngine:
266266
if not self.is_mapping_populated:
267267

268268
values = self._get_index_values()
269-
if values.dtype in {'int8', 'int16', 'int32'}:
270-
values = algos.ensure_int64(values)
271269
self.mapping = self._make_hash_table(len(values))
272270
self._call_map_locations(values)
273271

pandas/_libs/index_class_helper.pxi.in

+7
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ cdef class {{name}}Engine(IndexEngine):
4646
return _hash.{{name}}HashTable(n)
4747
{{endif}}
4848

49+
{{if name in {'Int8', 'Int16', 'Int32'} }}
50+
cpdef _call_map_locations(self, values):
51+
# we don't have Int8/16/32HashTable, so use Int64HashTable
52+
# and need to pass int64 values to it
53+
self.mapping.map_locations(algos.ensure_int64(values))
54+
{{endif}}
55+
4956
{{if name != 'Float64' and name != 'Object'}}
5057
cdef _check_type(self, object val):
5158
hash(val)

0 commit comments

Comments
 (0)