Skip to content

Commit 7aa2737

Browse files
jbrockmendeljreback
authored andcommitted
remove get_value_box since it is redundant with libindex.get_value_at (#18371)
1 parent 84bce21 commit 7aa2737

File tree

4 files changed

+29
-28
lines changed

4 files changed

+29
-28
lines changed

pandas/_libs/index.pyx

+25
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,31 @@ def get_value_at(ndarray arr, object loc):
4747
return util.get_value_at(arr, loc)
4848

4949

50+
cpdef object get_value_box(ndarray arr, object loc):
51+
cdef:
52+
Py_ssize_t i, sz
53+
54+
if util.is_float_object(loc):
55+
casted = int(loc)
56+
if casted == loc:
57+
loc = casted
58+
i = <Py_ssize_t> loc
59+
sz = cnp.PyArray_SIZE(arr)
60+
61+
if i < 0 and sz > 0:
62+
i += sz
63+
64+
if i >= sz or sz == 0 or i < 0:
65+
raise IndexError('index out of bounds')
66+
67+
if arr.descr.type_num == NPY_DATETIME:
68+
return Timestamp(util.get_value_1d(arr, i))
69+
elif arr.descr.type_num == NPY_TIMEDELTA:
70+
return Timedelta(util.get_value_1d(arr, i))
71+
else:
72+
return util.get_value_1d(arr, i)
73+
74+
5075
def set_value_at(ndarray arr, object loc, object val):
5176
return util.set_value_at(arr, loc, val)
5277

pandas/_libs/src/util.pxd

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ cdef extern from "headers/stdint.h":
5353
cdef inline object get_value_at(ndarray arr, object loc):
5454
cdef:
5555
Py_ssize_t i, sz
56-
void* data_ptr
56+
int casted
57+
5758
if is_float_object(loc):
5859
casted = int(loc)
5960
if casted == loc:

pandas/_libs/tslib.pyx

+1-26
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
cimport numpy as np
88
from numpy cimport (int32_t, int64_t, import_array, ndarray,
9-
float64_t, NPY_DATETIME, NPY_TIMEDELTA)
9+
float64_t)
1010
import numpy as np
1111

1212
import sys
@@ -847,31 +847,6 @@ cdef inline bint _check_all_nulls(object val):
847847
return res
848848

849849

850-
cpdef object get_value_box(ndarray arr, object loc):
851-
cdef:
852-
Py_ssize_t i, sz
853-
854-
if is_float_object(loc):
855-
casted = int(loc)
856-
if casted == loc:
857-
loc = casted
858-
i = <Py_ssize_t> loc
859-
sz = np.PyArray_SIZE(arr)
860-
861-
if i < 0 and sz > 0:
862-
i += sz
863-
864-
if i >= sz or sz == 0 or i < 0:
865-
raise IndexError('index out of bounds')
866-
867-
if arr.descr.type_num == NPY_DATETIME:
868-
return Timestamp(util.get_value_1d(arr, i))
869-
elif arr.descr.type_num == NPY_TIMEDELTA:
870-
return Timedelta(util.get_value_1d(arr, i))
871-
else:
872-
return util.get_value_1d(arr, i)
873-
874-
875850
# Add the min and max fields at the class level
876851
cdef int64_t _NS_UPPER_BOUND = INT64_MAX
877852
# the smallest value we could actually represent is

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2559,7 +2559,7 @@ def get_value(self, series, key):
25592559
raise
25602560

25612561
try:
2562-
return libts.get_value_box(s, key)
2562+
return libindex.get_value_box(s, key)
25632563
except IndexError:
25642564
raise
25652565
except TypeError:

0 commit comments

Comments
 (0)