Skip to content

Commit 436a429

Browse files
author
tp
committed
add Int8Index
1 parent 10f4ada commit 436a429

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

pandas/_libs/algos_common_helper.pxi.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ WARNING: DO NOT edit .pxi FILE directly, .pxi is generated from .pxi.in
2525
dtypes = [('float64', 'float64_t', 'np.float64', True, True),
2626
('float32', 'float32_t', 'np.float32', True, True),
2727
('object', 'object', 'object', True, False),
28-
('int32', 'int32_t', 'np.int32', False, True),
2928
('int64', 'int64_t', 'np.int64', False, True),
3029
('uint64', 'uint64_t', 'np.uint64', False, True),
30+
('int32', 'int32_t', 'np.int32', False, True),
31+
('int8', 'int8_t', 'np.int8', False, True),
3132
('bool', 'uint8_t', 'np.bool', False, True)]
3233

3334
def get_dispatch(dtypes):

pandas/_libs/index.pyx

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ from cpython.slice cimport PySlice_Check
88

99
import numpy as np
1010
cimport numpy as cnp
11-
from numpy cimport (ndarray, float64_t, int32_t,
12-
int64_t, uint8_t, uint64_t, intp_t)
11+
from numpy cimport (ndarray, float64_t,
12+
int8_t, int16_t, int32_t, int64_t,
13+
uint8_t, uint64_t,
14+
intp_t)
1315
cnp.import_array()
1416

1517
cdef extern from "numpy/arrayobject.h":

pandas/_libs/index_class_helper.pxi.in

+6-2
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

+6-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ class CategoricalIndex(Index, accessor.PandasDelegate):
7272
"""
7373

7474
_typ = 'categoricalindex'
75-
_engine_type = libindex.Int64Engine
75+
76+
@property
77+
def _engine_type(self):
78+
type_name = self.codes.dtype.name.capitalize()
79+
return getattr(libindex, "{}Engine".format(type_name))
7680
_attributes = ['name']
7781

7882
def __new__(cls, data=None, categories=None, ordered=None, dtype=None,
@@ -366,7 +370,7 @@ def argsort(self, *args, **kwargs):
366370
def _engine(self):
367371

368372
# we are going to look things up with the codes themselves
369-
return self._engine_type(lambda: self.codes.astype('i8'), len(self))
373+
return self._engine_type(lambda: self.codes, len(self))
370374

371375
# introspection
372376
@cache_readonly

0 commit comments

Comments
 (0)