@@ -195,11 +195,12 @@ def _tile_scalar(cls, op):
195195 out_chunks .append (out_chunk )
196196
197197 new_op = op .copy ()
198+ out = op .outputs [0 ]
198199 if isinstance (df , SERIES_TYPE ):
199- return new_op .new_seriess (op .inputs , df .shape , nsplits = tileable .nsplits , dtype = df .dtype ,
200+ return new_op .new_seriess (op .inputs , df .shape , nsplits = tileable .nsplits , dtype = out .dtype ,
200201 index_value = df .index_value , name = df .name , chunks = out_chunks )
201202 else :
202- return new_op .new_dataframes (op .inputs , df .shape , nsplits = tileable .nsplits , dtypes = df .dtypes ,
203+ return new_op .new_dataframes (op .inputs , df .shape , nsplits = tileable .nsplits , dtypes = out .dtypes ,
203204 index_value = df .index_value , columns_value = df .columns_value ,
204205 chunks = out_chunks )
205206
@@ -233,11 +234,12 @@ def _tile_with_tensor(cls, op):
233234 out_chunks .append (out_chunk )
234235
235236 new_op = op .copy ()
237+ out = op .outputs [0 ]
236238 if isinstance (other , SERIES_TYPE ):
237- return new_op .new_seriess (op .inputs , other .shape , nsplits = other .nsplits , dtype = other .dtype ,
238- index_value = other .index_value , name = other . name , chunks = out_chunks )
239+ return new_op .new_seriess (op .inputs , other .shape , nsplits = other .nsplits , dtype = out .dtype ,
240+ index_value = other .index_value , chunks = out_chunks )
239241 else :
240- return new_op .new_dataframes (op .inputs , other .shape , nsplits = other .nsplits , dtypes = other .dtypes ,
242+ return new_op .new_dataframes (op .inputs , other .shape , nsplits = other .nsplits , dtypes = out .dtypes ,
241243 index_value = other .index_value , columns_value = other .columns_value ,
242244 chunks = out_chunks )
243245
@@ -294,8 +296,17 @@ def _operator(self):
294296 def _calc_properties (cls , x1 , x2 = None , axis = 'columns' ):
295297 if isinstance (x1 , (DATAFRAME_TYPE , DATAFRAME_CHUNK_TYPE )) \
296298 and (x2 is None or np .isscalar (x2 ) or isinstance (x2 , TENSOR_TYPE )):
297- # FIXME infer the dtypes of result df properly
298- return {'shape' : x1 .shape , 'dtypes' : x1 .dtypes ,
299+ if x2 is None :
300+ dtypes = x1 .dtypes
301+ elif np .isscalar (x2 ):
302+ dtypes = infer_dtypes (x1 .dtypes , pd .Series (np .array (x2 ).dtype ), cls ._operator )
303+ elif x1 .dtypes is not None and isinstance (x2 , TENSOR_TYPE ):
304+ dtypes = pd .Series (
305+ [infer_dtype (dt , x2 .dtype , cls ._operator ) for dt in x1 .dtypes ],
306+ index = x1 .dtypes .index )
307+ else :
308+ dtypes = x1 .dtypes
309+ return {'shape' : x1 .shape , 'dtypes' : dtypes ,
299310 'columns_value' : x1 .columns_value , 'index_value' : x1 .index_value }
300311
301312 if isinstance (x1 , (SERIES_TYPE , SERIES_CHUNK_TYPE )) \
@@ -310,7 +321,9 @@ def _calc_properties(cls, x1, x2=None, axis='columns'):
310321
311322 if x1 .columns_value is not None and x2 .columns_value is not None and \
312323 x1 .columns_value .key == x2 .columns_value .key :
313- dtypes = x1 .dtypes
324+ dtypes = pd .Series ([infer_dtype (dt1 , dt2 , cls ._operator ) for dt1 , dt2
325+ in zip (x1 .dtypes , x2 .dtypes )],
326+ index = x1 .dtypes .index )
314327 columns = copy .copy (x1 .columns_value )
315328 columns .value .should_be_monotonic = False
316329 column_shape = len (dtypes )
@@ -342,11 +355,12 @@ def _calc_properties(cls, x1, x2=None, axis='columns'):
342355 column_shape , dtypes , columns = np .nan , None , None
343356 if x1 .columns_value is not None and x1 .index_value is not None :
344357 if x1 .columns_value .key == x2 .index_value .key :
345- dtypes = x1 .dtypes
358+ dtypes = pd .Series ([infer_dtype (dt , x2 .dtype , cls ._operator ) for dt in x1 .dtypes ],
359+ index = x1 .dtypes .index )
346360 columns = copy .copy (x1 .columns_value )
347361 columns .value .should_be_monotonic = False
348362 column_shape = len (dtypes )
349- else :
363+ else : # pragma: no cover
350364 dtypes = x1 .dtypes # FIXME
351365 columns = infer_index_value (x1 .columns_value , x2 .index_value )
352366 columns .value .should_be_monotonic = True
@@ -359,10 +373,16 @@ def _calc_properties(cls, x1, x2=None, axis='columns'):
359373 index_shape , index = np .nan , None
360374 if x1 .index_value is not None and x1 .index_value is not None :
361375 if x1 .index_value .key == x2 .index_value .key :
362- index = copy .copy (x1 .columns_value )
376+ dtypes = pd .Series ([infer_dtype (dt , x2 .dtype , cls ._operator ) for dt in x1 .dtypes ],
377+ index = x1 .dtypes .index )
378+ index = copy .copy (x1 .index_value )
363379 index .value .should_be_monotonic = False
364380 index_shape = x1 .shape [0 ]
365381 else :
382+ if x1 .dtypes is not None :
383+ dtypes = pd .Series (
384+ [infer_dtype (dt , x2 .dtype , cls ._operator ) for dt in x1 .dtypes ],
385+ index = x1 .dtypes .index )
366386 index = infer_index_value (x1 .index_value , x2 .index_value )
367387 index .value .should_be_monotonic = True
368388 index_shape = np .nan
0 commit comments