Skip to content

Commit decf1f2

Browse files
committed
Merge remote-tracking branch 'upstream/master' into rolling-groupby
2 parents 38121bf + b512ed5 commit decf1f2

34 files changed

+545
-525
lines changed

pandas/_libs/hashtable.pyx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ cdef class Factorizer:
8686
self, ndarray[object] values, sort=False, na_sentinel=-1, na_value=None
8787
):
8888
"""
89+
Examples
90+
--------
8991
Factorize values with nans replaced by na_sentinel
92+
9093
>>> factorize(np.array([1,2,np.nan], dtype='O'), na_sentinel=20)
9194
array([ 0, 1, 20])
9295
"""
@@ -131,7 +134,10 @@ cdef class Int64Factorizer:
131134
def factorize(self, const int64_t[:] values, sort=False,
132135
na_sentinel=-1, na_value=None):
133136
"""
137+
Examples
138+
--------
134139
Factorize values with nans replaced by na_sentinel
140+
135141
>>> factorize(np.array([1,2,np.nan], dtype='O'), na_sentinel=20)
136142
array([ 0, 1, 20])
137143
"""

pandas/_libs/index.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ cdef class IndexEngine:
115115
cdef _maybe_get_bool_indexer(self, object val):
116116
cdef:
117117
ndarray[uint8_t, ndim=1, cast=True] indexer
118-
ndarray[intp_t, ndim=1] found
119-
int count
120118

121119
indexer = self._get_index_values() == val
122120
return self._unpack_bool_indexer(indexer, val)

pandas/_libs/internals.pyx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ cdef class BlockPlacement:
105105
Py_ssize_t start, stop, end, _
106106
if not self._has_array:
107107
start, stop, step, _ = slice_get_indices_ex(self._as_slice)
108-
self._as_array = np.arange(start, stop, step,
109-
dtype=np.int64)
108+
self._as_array = np.arange(start, stop, step, dtype=np.int64)
110109
self._has_array = True
111110
return self._as_array
112111

@@ -283,8 +282,7 @@ cdef slice_getitem(slice slc, ind):
283282
s_start, s_stop, s_step, s_len = slice_get_indices_ex(slc)
284283

285284
if isinstance(ind, slice):
286-
ind_start, ind_stop, ind_step, ind_len = slice_get_indices_ex(ind,
287-
s_len)
285+
ind_start, ind_stop, ind_step, ind_len = slice_get_indices_ex(ind, s_len)
288286

289287
if ind_step > 0 and ind_len == s_len:
290288
# short-cut for no-op slice

pandas/_libs/interval.pyx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,7 @@ cdef class Interval(IntervalMixin):
481481

482482
@cython.wraparound(False)
483483
@cython.boundscheck(False)
484-
def intervals_to_interval_bounds(ndarray intervals,
485-
bint validate_closed=True):
484+
def intervals_to_interval_bounds(ndarray intervals, bint validate_closed=True):
486485
"""
487486
Parameters
488487
----------
@@ -502,14 +501,14 @@ def intervals_to_interval_bounds(ndarray intervals,
502501
"""
503502
cdef:
504503
object closed = None, interval
505-
int64_t n = len(intervals)
504+
Py_ssize_t i, n = len(intervals)
506505
ndarray left, right
507506
bint seen_closed = False
508507

509508
left = np.empty(n, dtype=intervals.dtype)
510509
right = np.empty(n, dtype=intervals.dtype)
511510

512-
for i in range(len(intervals)):
511+
for i in range(n):
513512
interval = intervals[i]
514513
if interval is None or util.is_nan(interval):
515514
left[i] = np.nan

pandas/_libs/join.pyx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -817,18 +817,22 @@ def asof_join_nearest_on_X_by_Y(asof_t[:] left_values,
817817
right_indexer = np.empty(left_size, dtype=np.int64)
818818

819819
# search both forward and backward
820-
bli, bri = asof_join_backward_on_X_by_Y(left_values,
821-
right_values,
822-
left_by_values,
823-
right_by_values,
824-
allow_exact_matches,
825-
tolerance)
826-
fli, fri = asof_join_forward_on_X_by_Y(left_values,
827-
right_values,
828-
left_by_values,
829-
right_by_values,
830-
allow_exact_matches,
831-
tolerance)
820+
bli, bri = asof_join_backward_on_X_by_Y(
821+
left_values,
822+
right_values,
823+
left_by_values,
824+
right_by_values,
825+
allow_exact_matches,
826+
tolerance,
827+
)
828+
fli, fri = asof_join_forward_on_X_by_Y(
829+
left_values,
830+
right_values,
831+
left_by_values,
832+
right_by_values,
833+
allow_exact_matches,
834+
tolerance,
835+
)
832836

833837
for i in range(len(bri)):
834838
# choose timestamp from right with smaller difference

0 commit comments

Comments
 (0)