-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Dtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsgood first issue
Description
Series.sum returns a numpy type, except when it's empty, in which case it returns a python int of value "0":
In [2]: type(pd.Series([0]).sum())
Out[2]: numpy.int64
In [3]: type(pd.Series().sum())
Out[3]: int
This poses a problem when I do 1 / myserie.sum()
because I expect to obtain np.inf
rather than a divison by 0 exception.
I think the return type of Series.sum()
for empty series should be inferred from the Series's dtype This way, Series([], dtype='str').sum()
would return an empty string, and Series([]).sum()
would return np.float64(0)
since an empty series' default type seems to be float64.
Tested with Pandas 0.16.0
Metadata
Metadata
Assignees
Labels
Dtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsgood first issue