Skip to content

Commit 25443f0

Browse files
authored
CLN: Some code cleanups (#32176)
1 parent 89d5f87 commit 25443f0

File tree

7 files changed

+152
-127
lines changed

7 files changed

+152
-127
lines changed

pandas/_libs/indexing.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cdef class _NDFrameIndexerBase:
22
"""
3-
A base class for _NDFrameIndexer for fast instantiation and attribute
4-
access.
3+
A base class for _NDFrameIndexer for fast instantiation and attribute access.
54
"""
65
cdef public object obj, name, _ndim
76

pandas/_libs/sparse.pyx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ cdef class IntIndex(SparseIndex):
188188
return -1
189189

190190
@cython.wraparound(False)
191-
cpdef ndarray[int32_t] lookup_array(self, ndarray[
192-
int32_t, ndim=1] indexer):
191+
cpdef ndarray[int32_t] lookup_array(self, ndarray[int32_t, ndim=1] indexer):
193192
"""
194193
Vectorized lookup, returns ndarray[int32_t]
195194
"""
@@ -424,12 +423,9 @@ cdef class BlockIndex(SparseIndex):
424423
"""
425424
Intersect two BlockIndex objects
426425
427-
Parameters
428-
----------
429-
430426
Returns
431427
-------
432-
intersection : BlockIndex
428+
BlockIndex
433429
"""
434430
cdef:
435431
BlockIndex y
@@ -518,7 +514,7 @@ cdef class BlockIndex(SparseIndex):
518514
519515
Returns
520516
-------
521-
union : BlockIndex
517+
BlockIndex
522518
"""
523519
return BlockUnion(self, y.to_block_index()).result
524520

@@ -548,8 +544,7 @@ cdef class BlockIndex(SparseIndex):
548544
return -1
549545

550546
@cython.wraparound(False)
551-
cpdef ndarray[int32_t] lookup_array(self, ndarray[
552-
int32_t, ndim=1] indexer):
547+
cpdef ndarray[int32_t] lookup_array(self, ndarray[int32_t, ndim=1] indexer):
553548
"""
554549
Vectorized lookup, returns ndarray[int32_t]
555550
"""

pandas/_libs/tslibs/conversion.pyx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,11 @@ def ensure_datetime64ns(arr: ndarray, copy: bool=True):
8484
Parameters
8585
----------
8686
arr : ndarray
87-
copy : boolean, default True
87+
copy : bool, default True
8888
8989
Returns
9090
-------
91-
result : ndarray with dtype datetime64[ns]
92-
91+
ndarray with dtype datetime64[ns]
9392
"""
9493
cdef:
9594
Py_ssize_t i, n = arr.size

pandas/_libs/tslibs/resolution.pyx

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ def get_freq_group(freq) -> int:
110110
"""
111111
Return frequency code group of given frequency str or offset.
112112

113-
Example
114-
-------
113+
Examples
114+
--------
115115
>>> get_freq_group('W-MON')
116116
4000
117117

@@ -193,8 +193,8 @@ class Resolution:
193193
"""
194194
Return resolution str against resolution code.
195195

196-
Example
197-
-------
196+
Examples
197+
--------
198198
>>> Resolution.get_str(Resolution.RESO_SEC)
199199
'second'
200200
"""
@@ -205,8 +205,8 @@ class Resolution:
205205
"""
206206
Return resolution str against resolution code.
207207

208-
Example
209-
-------
208+
Examples
209+
--------
210210
>>> Resolution.get_reso('second')
211211
2
212212

@@ -220,8 +220,8 @@ class Resolution:
220220
"""
221221
Return frequency str against resolution str.
222222

223-
Example
224-
-------
223+
Examples
224+
--------
225225
>>> f.Resolution.get_freq_group('day')
226226
4000
227227
"""
@@ -232,8 +232,8 @@ class Resolution:
232232
"""
233233
Return frequency str against resolution str.
234234

235-
Example
236-
-------
235+
Examples
236+
--------
237237
>>> f.Resolution.get_freq('day')
238238
'D'
239239
"""
@@ -244,8 +244,8 @@ class Resolution:
244244
"""
245245
Return resolution str against frequency str.
246246

247-
Example
248-
-------
247+
Examples
248+
--------
249249
>>> Resolution.get_str_from_freq('H')
250250
'hour'
251251
"""
@@ -256,8 +256,8 @@ class Resolution:
256256
"""
257257
Return resolution code against frequency str.
258258

259-
Example
260-
-------
259+
Examples
260+
--------
261261
>>> Resolution.get_reso_from_freq('H')
262262
4
263263

@@ -273,17 +273,17 @@ class Resolution:
273273
274274
Parameters
275275
----------
276-
value : integer or float
277-
freq : string
276+
value : int or float
277+
freq : str
278278
Frequency string
279279
280280
Raises
281281
------
282282
ValueError
283283
If the float cannot be converted to an integer at any resolution.
284284
285-
Example
286-
-------
285+
Examples
286+
--------
287287
>>> Resolution.get_stride_from_decimal(1.5, 'T')
288288
(90, 'S')
289289
@@ -298,8 +298,9 @@ class Resolution:
298298
else:
299299
start_reso = cls.get_reso_from_freq(freq)
300300
if start_reso == 0:
301-
raise ValueError("Could not convert to integer offset "
302-
"at any resolution")
301+
raise ValueError(
302+
"Could not convert to integer offset at any resolution"
303+
)
303304

304305
next_value = cls._reso_mult_map[start_reso] * value
305306
next_name = cls._reso_str_bump_map[freq]

0 commit comments

Comments
 (0)