Skip to content

Commit ece0517

Browse files
authored
CLN: some code cleanups (#32177)
1 parent 26de103 commit ece0517

File tree

8 files changed

+169
-101
lines changed

8 files changed

+169
-101
lines changed

pandas/_libs/hashtable.pyx

+6
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/internals.pyx

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

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

pandas/_libs/join.pyx

+16-12
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)