@@ -975,12 +975,12 @@ def _prepare_blocks(self):
975
975
data = data .consolidate ()
976
976
type_map = dict ((type (blk ), blk ) for blk in data .blocks )
977
977
blockmaps .append (type_map )
978
- return blockmaps
978
+ return blockmaps , reindexed_data
979
979
980
980
def _get_concatenated_data (self ):
981
981
try :
982
982
# need to conform to same other (joined) axes for block join
983
- blockmaps = self ._prepare_blocks ()
983
+ blockmaps , rdata = self ._prepare_blocks ()
984
984
kinds = _get_all_block_kinds (blockmaps )
985
985
986
986
new_blocks = []
@@ -1004,7 +1004,7 @@ def _get_concatenated_data(self):
1004
1004
1005
1005
new_data = {}
1006
1006
for item in self .new_axes [0 ]:
1007
- new_data [item ] = self ._concat_single_item (item )
1007
+ new_data [item ] = self ._concat_single_item (rdata , item )
1008
1008
1009
1009
return new_data
1010
1010
@@ -1053,15 +1053,20 @@ def _concat_blocks(self, blocks):
1053
1053
1054
1054
return make_block (concat_values , concat_items , self .new_axes [0 ])
1055
1055
1056
- def _concat_single_item (self , item ):
1056
+ def _concat_single_item (self , objs , item ):
1057
1057
all_values = []
1058
1058
dtypes = set ()
1059
- for obj in self .objs :
1060
- try :
1061
- values = obj ._data .get (item )
1059
+
1060
+ # le sigh
1061
+ if isinstance (self .objs [0 ], SparseDataFrame ):
1062
+ objs = [x ._data for x in self .objs ]
1063
+
1064
+ for data , orig in zip (objs , self .objs ):
1065
+ if item in orig :
1066
+ values = data .get (item )
1062
1067
dtypes .add (values .dtype )
1063
1068
all_values .append (values )
1064
- except KeyError :
1069
+ else :
1065
1070
all_values .append (None )
1066
1071
1067
1072
# this stinks
@@ -1075,9 +1080,9 @@ def _concat_single_item(self, item):
1075
1080
empty_dtype = np .float64
1076
1081
1077
1082
to_concat = []
1078
- for obj , item_values in zip (self . objs , all_values ):
1083
+ for obj , item_values in zip (objs , all_values ):
1079
1084
if item_values is None :
1080
- shape = obj ._data . shape [1 :]
1085
+ shape = obj .shape [1 :]
1081
1086
missing_arr = np .empty (shape , dtype = empty_dtype )
1082
1087
missing_arr .fill (np .nan )
1083
1088
to_concat .append (missing_arr )
0 commit comments