Skip to content

_reduce promotes numerics to strings when axis=0 and mixed type. #6806

Closed
@dalejung

Description

@dalejung
import pandas as pd
import numpy as np

df = pd.DataFrame({'num':[1,2,3], 'num2': np.random.randn(3), 'strings':list('abc')})
df.sum().values # array(['6', '-1.47818918058', 'abc'], dtype=object)

The issue is that axis=0 tries to coerce the dtypes and np.array will promote the numerics to strings.

Note that:

df.T.sum(axis=1).values # array([6, -1.4781891805780178, 'abc'], dtype=object)

Maybe com._coerce_to_dtypes should just return the list?

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