Skip to content

Collect Index methods by purpose: rendering, constructors, setops... #23961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 28, 2018
5,344 changes: 2,701 additions & 2,643 deletions pandas/core/indexes/base.py

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions pandas/core/indexes/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ def _engine_type(self):

_attributes = ['name']

# --------------------------------------------------------------------
# Constructors

def __new__(cls, data=None, categories=None, ordered=None, dtype=None,
copy=False, name=None, fastpath=None):

Expand Down Expand Up @@ -212,6 +215,8 @@ def _simple_new(cls, values, name=None, categories=None, ordered=None,
result._reset_identity()
return result

# --------------------------------------------------------------------

@Appender(_index_shared_docs['_shallow_copy'])
def _shallow_copy(self, values=None, categories=None, ordered=None,
dtype=None, **kwargs):
Expand Down Expand Up @@ -284,6 +289,9 @@ def equals(self, other):

return False

# --------------------------------------------------------------------
# Rendering Methods

@property
def _formatter_func(self):
return self.categories._formatter_func
Expand All @@ -307,6 +315,8 @@ def _format_attrs(self):
attrs.append(('length', len(self)))
return attrs

# --------------------------------------------------------------------

@property
def inferred_type(self):
return 'categorical'
Expand Down
11 changes: 8 additions & 3 deletions pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,6 @@ def _box_values_as_index(self):
from pandas.core.index import Index
return Index(self._box_values(self.asi8), name=self.name, dtype=object)

def _format_with_header(self, header, **kwargs):
return header + list(self._format_native_types(**kwargs))

@Appender(_index_shared_docs['__contains__'] % _index_doc_kwargs)
def __contains__(self, key):
try:
Expand Down Expand Up @@ -544,6 +541,12 @@ def argmax(self, axis=None, *args, **kwargs):
i8[mask] = 0
return i8.argmax()

# --------------------------------------------------------------------
# Rendering Methods

def _format_with_header(self, header, **kwargs):
return header + list(self._format_native_types(**kwargs))

@property
def _formatter_func(self):
raise AbstractMethodError(self)
Expand All @@ -561,6 +564,8 @@ def _format_attrs(self):
attrs.append(('freq', freq))
return attrs

# --------------------------------------------------------------------

def _convert_scalar_indexer(self, key, kind=None):
"""
We don't allow integer or float indexing on datetime-like when using
Expand Down
Loading