Skip to content

Need to exclude NA values with dtype=object in stat methods #469

Closed
@wesm

Description

@wesm

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions