wesm/pandas — Issue #469: Need to exclude NA values with dtype=object in stat methods
Author: wesm
Created: 2011-12-11 23:47:42+00:00
State: open
Labels: Bug

reported by @npinger, regression from 0.5.0 I think.

import pandas
lis = [1, 3, 5, None, 7]
index = [1, 2, 3, 4, 5]
ser = pandas.core.series.Series(data=lis, index=index)
ser.mean()

Gives this error:

Traceback (most recent call last):
File "", line 1, in
File ".../pandas/core/series.py", line 650, in mean
return nanops.nanmean(self.values, skipna=skipna)
File ".../pandas/core/nanops.py", line 30, in nanmean
the_mean = values.sum(axis) / float(values.shape[axis])
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

import pandas
import numpy as np
lis = [1, 3, 5, np.nan, 7]
index = [1, 2, 3, 4, 5]
ser = pandas.core.series.Series(data=lis, index=index)
ser.mean()
(gives no error)