Skip to content

Different behaviour when assigning None using loc[] and [] #7647

Closed
@socheon

Description

@socheon
import pandas as pd
import numpy as np 

ser = pd.Series(['a', 'b', np.nan])
print ser

ser.loc[ser.isnull()] = None
print ser

ser[ser.isnull()] = None
print ser 

Output

0      a
1      b
2    NaN
dtype: object
0       a
1       b
2    None
dtype: object
0      a
1      b
2    NaN
dtype: object

I am not sure whether this behaviour is intentional. Using .loc[], None was correctly assigned but when using [], NaN was assigned instead. Thanks

I am using version 0.14.0-169-g7684b6e

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions