Skip to content

Commit efce8fc

Browse files
committed
REF: do concat on values, avoid blocks
1 parent 9c1984c commit efce8fc

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

pandas/core/internals/concat.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# TODO: Needs a better name; too many modules are already called "concat"
22
from collections import defaultdict
33
import copy
4+
from typing import List
45

56
import numpy as np
67

@@ -419,13 +420,15 @@ def _get_empty_dtype_and_na(join_units):
419420
raise AssertionError(msg)
420421

421422

422-
def _is_uniform_join_units(join_units) -> bool:
423+
def _is_uniform_join_units(join_units: List[JoinUnit]) -> bool:
423424
"""
424425
Check if the join units consist of blocks of uniform type that can
425426
be concatenated using Block.concat_same_type instead of the generic
426427
_concatenate_join_units (which uses `concat_compat`).
427428
428429
"""
430+
# TODO: require dtype match in addition to same type? e.g. DatetimeTZBlock
431+
# cannot necessarily join
429432
return (
430433
# all blocks need to have the same type
431434
all(type(ju.block) is type(join_units[0].block) for ju in join_units)

pandas/core/internals/managers.py

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from pandas.core.dtypes.common import (
2121
DT64NS_DTYPE,
2222
is_datetimelike_v_numeric,
23+
is_dtype_equal,
2324
is_extension_array_dtype,
2425
is_list_like,
2526
is_numeric_v_string_like,
@@ -42,6 +43,7 @@
4243
DatetimeTZBlock,
4344
ExtensionBlock,
4445
ObjectValuesExtensionBlock,
46+
_block_shape,
4547
_extend_blocks,
4648
_safe_reshape,
4749
get_block_type,

pandas/tests/extension/test_external_block.py

-6
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ def df():
3232
return pd.DataFrame(block_manager)
3333

3434

35-
def test_concat_dataframe(df):
36-
# GH17728
37-
res = pd.concat([df, df])
38-
assert isinstance(res._mgr.blocks[1], CustomBlock)
39-
40-
4135
def test_concat_axis1(df):
4236
# GH17954
4337
df2 = pd.DataFrame({"c": [0.1, 0.2, 0.3]})

0 commit comments

Comments
 (0)