Skip to content

Commit 444209d

Browse files
author
Daniel Saxton
committed
Use try / except on empty Series
1 parent bc65fe6 commit 444209d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pandas/core/apply.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,12 @@ def apply_empty_result(self):
213213
pass
214214

215215
if reduce:
216-
return self.obj._constructor_sliced(np.nan, index=self.agg_axis)
216+
try:
217+
r = self.f(Series([]), *self.args, **self.kwds)
218+
except:
219+
r = np.nan
220+
221+
return self.obj._constructor_sliced(r, index=self.agg_axis)
217222
else:
218223
return self.obj.copy()
219224

0 commit comments

Comments
 (0)