Skip to content
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

ENH: general concat with ExtensionArrays through find_common_type #33607

Merged
merged 14 commits into from
May 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update EA interface docs
  • Loading branch information
jorisvandenbossche committed May 1, 2020
commit 8893165c688c1d6881e0f6455ca4aa10ccb64eac
7 changes: 6 additions & 1 deletion pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ def _concat_same_type(
cls, to_concat: Sequence["ExtensionArray"]
) -> "ExtensionArray":
"""
Concatenate multiple array.
Concatenate multiple array of this dtype.

Parameters
----------
Expand All @@ -1014,6 +1014,11 @@ def _concat_same_type(
-------
ExtensionArray
"""
# Implementer note: this method will only be called with a sequence of
# ExtensionArrays of this class and with the same dtype as self. This
# should allow "easy" concatenation (no upcasting needed), and result
# in a new ExtensionArray of the same dtype.
# Note: this strict behaviour is only guaranteed starting with pandas 1.1
raise AbstractMethodError(cls)

# The _can_hold_na attribute is set to True so that pandas internals
Expand Down
6 changes: 4 additions & 2 deletions pandas/core/dtypes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ class ExtensionDtype:
* type
* name

The following attributes influence the behavior of the dtype in
The following attributes and methods influence the behavior of the dtype in
pandas operations

* _is_numeric
* _is_boolean
* _get_common_dtype

Optionally one can override construct_array_type for construction
with the name of this dtype via the Registry. See
Expand Down Expand Up @@ -333,7 +334,8 @@ def _get_common_dtype(self, dtypes: List[DtypeObj]) -> Optional[DtypeObj]:

If no common dtype exists, return None (which gives the other dtypes
the chance to determine a common dtype). If all dtypes in the list
return None, then the common dtype will be "object" dtype.
return None, then the common dtype will be "object" dtype (this means
it is never needed to return "object" dtype from this method itself).

Parameters
----------
Expand Down