Skip to content

BUG: nanops._ensure_numeric can't handle object dtypes containing complex objects #7415

Closed
@toddrjen

Description

@toddrjen

nanops._ensure_numeric is used to make sure ndarrays are a numeric dtype. However, it can't handle the case where the dtype is object and one or more of the axes is complex:

>>> from pandas.core.nanops import nanmean
>>> import numpy as np
>>> 
>>> value = np.vstack([np.array(np.nan).astype('O'), np.array(1+1j).astype('O')])
>>> nanmean(value, axis=0)
TypeError: can't convert complex to float

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsNumeric OperationsArithmetic, Comparison, and Logical operations

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions