Skip to content

where method results in a different outputs when using the inplace kwarg #22051

Closed
@finete

Description

@finete

I am getting different results when using the where method with inplace=False vs inplace=True.

consider the following dataframe:

df = pd.DataFrame({'a':[1,None,3]})
df
    a
0   1.0
1   Nan
2   3.0

when using the where method with inplace=False (the default), i get the following result:

df.where(pd.notnull(df), None)
    a
0   1.0
1   None
2   3.0

with a being converted to be of type object.

however if i do this:

df.where(pd.notnull(df), None, inplace=True)
df
    a
0   1.0
1   Nan
2   3.0

a is of type float64

pandas version: 0.23.3 , numpy version: 1.14.5

reported because of my question on SO

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TestsUnit test(s) needed to prevent regressionsgood first issueinplaceRelating to inplace parameter or equivalent

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions