Skip to content

BUG: where incorrectly coerces to str #9280

Closed
@sinhrks

Description

@sinhrks

Replacing some numeric values using where affects to dtype unrelated to the condition.

s = pd.Series(np.random.randn(5))
u = s.where(s<0, 'X', axis=1)
u
#0     -1.01421184508
#1                  X
#2                  X
#3    -0.228117839063
#4    -0.393903873887
# dtype: object

The result looks OK, but internally coerced to all str.

u.apply(type)
#0    <type 'str'>
#1    <type 'str'>
#2    <type 'str'>
#3    <type 'str'>
#4    <type 'str'>
# dtype: object

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