Skip to content

Commit 240e8f6

Browse files
committed
Various cleanups
1 parent b5f736d commit 240e8f6

File tree

5 files changed

+12
-25
lines changed

5 files changed

+12
-25
lines changed

pandas/core/arrays/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"""An interface for extending pandas with custom arrays."""
22
import abc
33

4-
import numpy as np
5-
64
from pandas.compat import add_metaclass
75

86

@@ -11,7 +9,7 @@
119

1210
@add_metaclass(abc.ABCMeta)
1311
class ExtensionArray(object):
14-
"""Abstract base class for custom array types
12+
"""Abstract base class for custom array types.
1513
1614
Notes
1715
-----
@@ -23,6 +21,9 @@ class ExtensionArray(object):
2321
* Extension arrays should be able to be constructed with instances of
2422
the class, i.e. ``ExtensionArray(extension_array)`` should return
2523
an instance, not error.
24+
25+
Additionally, certain methods and interfaces are required for proper
26+
this array to be properly stored inside a ``DataFrame`` or ``Series``.
2627
"""
2728
# ------------------------------------------------------------------------
2829
# Must be a Sequence

pandas/core/arrays/categorical.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,8 +2132,7 @@ def repeat(self, repeats, *args, **kwargs):
21322132
return self._constructor(values=codes, categories=self.categories,
21332133
ordered=self.ordered, fastpath=True)
21342134

2135-
# Interface things
2136-
# can_hold_na, concat_same_type, formatting_values
2135+
# ExtensionArray Interface things
21372136
@property
21382137
def _can_hold_na(self):
21392138
return True

pandas/core/dtypes/base.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
@add_metaclass(abc.ABCMeta)
88
class ExtensionDtype(object):
9-
"""A custom data type for your array.
9+
"""A custom data type, to be paired with an ExtensionArray.
1010
"""
1111

1212
def __str__(self):
@@ -16,7 +16,7 @@ def __str__(self):
1616
@abc.abstractmethod
1717
def type(self):
1818
# type: () -> type
19-
"""The scalar type for your array, e.g. ``int``
19+
"""The scalar type for the array, e.g. ``int``
2020
2121
It's expected ``ExtensionArray[item]`` returns an instance
2222
of ``ExtensionDtype.type`` for scalar ``item``.
@@ -27,9 +27,9 @@ def kind(self):
2727
# type () -> str
2828
"""A character code (one of 'biufcmMOSUV'), default 'O'
2929
30-
This should match the NumPy dtype used when your array is
30+
This should match the NumPy dtype used when the array is
3131
converted to an ndarray, which is probably 'O' for object if
32-
your extension type cannot be represented as a built-in NumPy
32+
the extension type cannot be represented as a built-in NumPy
3333
type.
3434
3535
See Also
@@ -71,11 +71,6 @@ def construct_from_string(cls, string):
7171
TypeError
7272
If a class cannot be constructed from this 'string'.
7373
74-
Notes
75-
-----
76-
The default implementation checks if 'string' matches your
77-
type's name. If so, it calls your class with no arguments.
78-
7974
Examples
8075
--------
8176
If the extension dtype can be constructed without any arguments,

pandas/core/dtypes/common.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,7 @@ def is_extension_type(arr):
16861686

16871687

16881688
def is_extension_array_dtype(arr_or_dtype):
1689-
"""Check if an object is a pandas extension array type
1689+
"""Check if an object is a pandas extension array type.
16901690
16911691
Parameters
16921692
----------
@@ -1702,9 +1702,6 @@ def is_extension_array_dtype(arr_or_dtype):
17021702
array interface. In pandas, this includes:
17031703
17041704
* Categorical
1705-
* PeriodArray
1706-
* IntervalArray
1707-
* SparseArray
17081705
17091706
Third-party libraries may implement arrays or types satisfying
17101707
this interface as well.

pandas/core/internals.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,13 +1848,8 @@ def take_nd(self, indexer, axis=0, new_mgr_locs=None, fill_tuple=None):
18481848
return self.make_block_same_class(new_values, new_mgr_locs)
18491849

18501850
def _can_hold_element(self, element):
1851-
# XXX:
1852-
# Not defined on NCM.
1853-
# Categorical got True from ObjectBlock
1854-
# DatetimeTZ gets DatetimeBlock
1855-
# Sparse gets Block
1856-
# Let's just assume yes for now, but we can maybe push
1857-
# this onto the array.
1851+
# XXX: We may need to think about pushing this onto the array.
1852+
# We're doing the same as CategoricalBlock here.
18581853
return True
18591854

18601855
def convert(self, copy=True, **kwargs):

0 commit comments

Comments
 (0)