Skip to content

Commit 91ee55d

Browse files
tptopper-123
authored andcommitted
add Int8Index
1 parent 297ec19 commit 91ee55d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

pandas/_libs/index_class_helper.pxi.in

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ WARNING: DO NOT edit .pxi FILE directly, .pxi is generated from .pxi.in
1212

1313
# name, dtype, ctype
1414
dtypes = [('Float64', 'float64', 'float64_t'),
15-
('UInt64', 'uint64', 'uint64_t'),
1615
('Int64', 'int64', 'int64_t'),
17-
('Object', 'object', 'object')]
16+
('Int32', 'int32', 'int32_t'),
17+
('Int16', 'int16', 'int16_t'),
18+
('Int8', 'int8', 'int8_t'),
19+
('UInt64', 'uint64', 'uint64_t'),
20+
('Object', 'object', 'object'),
21+
]
1822
}}
1923

2024
{{for name, dtype, ctype in dtypes}}

pandas/core/indexes/category.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ class CategoricalIndex(Index, accessor.PandasDelegate):
8383
"""
8484

8585
_typ = 'categoricalindex'
86-
_engine_type = libindex.Int64Engine
86+
87+
@property
88+
def _engine_type(self):
89+
type_name = self.codes.dtype.name.capitalize()
90+
return getattr(libindex, "{}Engine".format(type_name))
8791
_attributes = ['name']
8892

8993
def __new__(cls, data=None, categories=None, ordered=None, dtype=None,
@@ -377,7 +381,7 @@ def argsort(self, *args, **kwargs):
377381
def _engine(self):
378382

379383
# we are going to look things up with the codes themselves
380-
return self._engine_type(lambda: self.codes.astype('i8'), len(self))
384+
return self._engine_type(lambda: self.codes, len(self))
381385

382386
# introspection
383387
@cache_readonly

0 commit comments

Comments
 (0)