From daac0c84aaae62c592d0e99563ae16a677ce3c7c Mon Sep 17 00:00:00 2001 From: Matthew Kirk Date: Mon, 1 Jan 2018 08:45:28 -0800 Subject: [PATCH] fix: must either be empty or all are sparse --- pandas/core/dtypes/concat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/dtypes/concat.py b/pandas/core/dtypes/concat.py index 274a56bc53dec6..956a209290411d 100644 --- a/pandas/core/dtypes/concat.py +++ b/pandas/core/dtypes/concat.py @@ -89,10 +89,10 @@ def _get_series_result_type(result, objs=None): def _get_frame_result_type(result, objs): """ return appropriate class of DataFrame-like concat - if any block is SparseBlock, return SparseDataFrame + if all blocks are SparseBlock, return SparseDataFrame otherwise, return 1st obj """ - if all(b.is_sparse for b in result.blocks): + if result.blocks and all(b.is_sparse for b in result.blocks): from pandas.core.sparse.api import SparseDataFrame return SparseDataFrame else: