Skip to content

REF: de-privatize dtypes.concat functions #27499

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 6 commits into from
Jul 22, 2019
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
de-privatize _concat_datetime
  • Loading branch information
jbrockmendel committed Jul 20, 2019
commit 524a19fa044ce378d0f67f42a555c1e6a0ca8856
6 changes: 3 additions & 3 deletions pandas/core/dtypes/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ def is_nonempty(x):
_contains_period = any(typ.startswith("period") for typ in typs)

if "category" in typs:
# this must be prior to _concat_datetime,
# this must be prior to concat_datetime,
# to support Categorical + datetime-like
return concat_categorical(to_concat, axis=axis)

elif _contains_datetime or "timedelta" in typs or _contains_period:
return _concat_datetime(to_concat, axis=axis, typs=typs)
return concat_datetime(to_concat, axis=axis, typs=typs)

# these are mandated to handle empties as well
elif "sparse" in typs:
Expand Down Expand Up @@ -404,7 +404,7 @@ def _concatenate_2d(to_concat, axis):
return np.concatenate(to_concat, axis=axis)


def _concat_datetime(to_concat, axis=0, typs=None):
def concat_datetime(to_concat, axis=0, typs=None):
"""
provide concatenation of an datetimelike array of arrays each of which is a
single M8[ns], datetimet64[ns, tz] or m8[ns] dtype
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
is_timedelta64_dtype,
pandas_dtype,
)
import pandas.core.dtypes.concat as _concat
from pandas.core.dtypes.concat import concat_categorical, concat_datetime
from pandas.core.dtypes.dtypes import CategoricalDtype, ExtensionDtype
from pandas.core.dtypes.generic import (
ABCDataFrame,
Expand Down Expand Up @@ -2559,7 +2559,7 @@ def concat_same_type(self, to_concat, placement=None):
# Instead of placing the condition here, it could also go into the
# is_uniform_join_units check, but I'm not sure what is better.
if len({x.dtype for x in to_concat}) > 1:
values = _concat._concat_datetime([x.values for x in to_concat])
values = concat_datetime([x.values for x in to_concat])
placement = placement or slice(0, len(values), 1)

if self.ndim > 1:
Expand Down Expand Up @@ -3092,7 +3092,7 @@ class CategoricalBlock(ExtensionBlock):
is_categorical = True
_verify_integrity = True
_can_hold_na = True
_concatenator = staticmethod(_concat.concat_categorical)
_concatenator = staticmethod(concat_categorical)

def __init__(self, values, placement, ndim=None):
from pandas.core.arrays.categorical import _maybe_to_categorical
Expand Down