Skip to content

Commit

Permalink
Fixed bug pandas-dev#9733 where stat functions returned a python scal…
Browse files Browse the repository at this point in the history
…ar for empty series
  • Loading branch information
remiremi committed Apr 7, 2015
1 parent 3149a1e commit a796032
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pandas/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def f(values, axis=None, skipna=True, **kwds):
# wrap the 0's if needed
if is_timedelta64_dtype(values):
return lib.Timedelta(0)
return 0
return values.dtype.type(0)
else:
result_shape = (values.shape[:axis] +
values.shape[axis + 1:])
Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2592,6 +2592,12 @@ def testit():
self.assertRaisesRegexp(NotImplementedError, name, f,
self.series, numeric_only=True)

# Test type of empty Series
s = Series()
self.assertEqual(s.dtype, s.sum().dtype)
s = Series(dtype=np.int64)
self.assertEqual(s.dtype, s.sum().dtype)

testit()

try:
Expand Down

0 comments on commit a796032

Please sign in to comment.