Skip to content

Commit 9afa6f1

Browse files
authored
PERF: concat in no-reindexing case (#53772)
1 parent 644c10d commit 9afa6f1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/core/internals/concat.py

+9
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,15 @@ def _concat_homogeneous_fastpath(
254254
"""
255255
# assumes
256256
# all(_is_homogeneous_mgr(mgr, first_dtype) for mgr, _ in in mgrs_indexers)
257+
258+
if all(not indexers for _, indexers in mgrs_indexers):
259+
# https://github.com/pandas-dev/pandas/pull/52685#issuecomment-1523287739
260+
arrs = [mgr.blocks[0].values.T for mgr, _ in mgrs_indexers]
261+
arr = np.concatenate(arrs).T
262+
bp = libinternals.BlockPlacement(slice(shape[0]))
263+
nb = new_block_2d(arr, bp)
264+
return nb
265+
257266
arr = np.empty(shape, dtype=first_dtype)
258267

259268
if first_dtype == np.float64:

0 commit comments

Comments
 (0)