@@ -251,7 +251,13 @@ def aggregate(self, func=None, *args, **kwargs):
251251 result = self ._aggregate_named (func , * args , ** kwargs )
252252
253253 index = Index (sorted (result ), name = self .grouper .names [0 ])
254- ret = Series (result , index = index )
254+
255+ # TODO: if/else can be removed as soon as default dtype
256+ # for empty series is changed object
257+ if result :
258+ ret = Series (result , index = index )
259+ else :
260+ ret = Series (result , index = index , dtype = object )
255261
256262 if not self .as_index : # pragma: no cover
257263 print ("Warning, ignoring as_index=True" )
@@ -348,7 +354,7 @@ def _wrap_transformed_output(self, output, names=None):
348354 def _wrap_applied_output (self , keys , values , not_indexed_same = False ):
349355 if len (keys ) == 0 :
350356 # GH #6265
351- return Series ([], name = self ._selection_name , index = keys )
357+ return Series ([], name = self ._selection_name , index = keys , dtype = np . float64 )
352358
353359 def _get_index () -> Index :
354360 if self .grouper .nkeys > 1 :
@@ -430,7 +436,7 @@ def transform(self, func, *args, **kwargs):
430436
431437 result = concat (results ).sort_index ()
432438 else :
433- result = Series ()
439+ result = Series (dtype = np . float64 )
434440
435441 # we will only try to coerce the result type if
436442 # we have a numeric dtype, as these are *always* udfs
@@ -1164,9 +1170,17 @@ def first_not_none(values):
11641170 if v is None :
11651171 return DataFrame ()
11661172 elif isinstance (v , NDFrame ):
1173+
1174+ # this is to silence a FutureWarning
1175+ # TODO: Remove when default dtype of empty Series is object
1176+ kwargs = v ._construct_axes_dict ()
1177+ if v ._constructor is Series :
1178+ is_empty = "data" not in kwargs or not kwargs ["data" ]
1179+ if "dtype" not in kwargs and is_empty :
1180+ kwargs ["dtype" ] = object
1181+
11671182 values = [
1168- x if x is not None else v ._constructor (** v ._construct_axes_dict ())
1169- for x in values
1183+ x if (x is not None ) else v ._constructor (** kwargs ) for x in values
11701184 ]
11711185
11721186 v = values [0 ]
0 commit comments