Skip to content

Commit 30c1290

Browse files
jbrockmendeljreback
authored andcommitted
Collect Index methods by purpose: rendering, constructors, setops... (#23961)
1 parent 2712c8f commit 30c1290

File tree

9 files changed

+3227
-3107
lines changed

9 files changed

+3227
-3107
lines changed

pandas/core/indexes/base.py

+2,701-2,643
Large diffs are not rendered by default.

pandas/core/indexes/category.py

+10
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ def _engine_type(self):
9494

9595
_attributes = ['name']
9696

97+
# --------------------------------------------------------------------
98+
# Constructors
99+
97100
def __new__(cls, data=None, categories=None, ordered=None, dtype=None,
98101
copy=False, name=None, fastpath=None):
99102

@@ -212,6 +215,8 @@ def _simple_new(cls, values, name=None, categories=None, ordered=None,
212215
result._reset_identity()
213216
return result
214217

218+
# --------------------------------------------------------------------
219+
215220
@Appender(_index_shared_docs['_shallow_copy'])
216221
def _shallow_copy(self, values=None, categories=None, ordered=None,
217222
dtype=None, **kwargs):
@@ -284,6 +289,9 @@ def equals(self, other):
284289

285290
return False
286291

292+
# --------------------------------------------------------------------
293+
# Rendering Methods
294+
287295
@property
288296
def _formatter_func(self):
289297
return self.categories._formatter_func
@@ -307,6 +315,8 @@ def _format_attrs(self):
307315
attrs.append(('length', len(self)))
308316
return attrs
309317

318+
# --------------------------------------------------------------------
319+
310320
@property
311321
def inferred_type(self):
312322
return 'categorical'

pandas/core/indexes/datetimelike.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,6 @@ def _box_values_as_index(self):
331331
from pandas.core.index import Index
332332
return Index(self._box_values(self.asi8), name=self.name, dtype=object)
333333

334-
def _format_with_header(self, header, **kwargs):
335-
return header + list(self._format_native_types(**kwargs))
336-
337334
@Appender(_index_shared_docs['__contains__'] % _index_doc_kwargs)
338335
def __contains__(self, key):
339336
try:
@@ -544,6 +541,12 @@ def argmax(self, axis=None, *args, **kwargs):
544541
i8[mask] = 0
545542
return i8.argmax()
546543

544+
# --------------------------------------------------------------------
545+
# Rendering Methods
546+
547+
def _format_with_header(self, header, **kwargs):
548+
return header + list(self._format_native_types(**kwargs))
549+
547550
@property
548551
def _formatter_func(self):
549552
raise AbstractMethodError(self)
@@ -561,6 +564,8 @@ def _format_attrs(self):
561564
attrs.append(('freq', freq))
562565
return attrs
563566

567+
# --------------------------------------------------------------------
568+
564569
def _convert_scalar_indexer(self, key, kind=None):
565570
"""
566571
We don't allow integer or float indexing on datetime-like when using

0 commit comments

Comments
 (0)