Skip to content

BUG: astype assignment with loc not working #5702

Closed
@TomAugspurger

Description

@TomAugspurger
In [10]: df = pd.DataFrame({'A': [1., 2., 3., 4.]})

In [11]: df.dtypes
Out[11]: 
A    float64
dtype: object

In [12]: df.loc[:, 'A'] = df['A'].astype(np.int64)

In [13]: df.dtypes
Out[13]: 
A    float64
dtype: object

#4624 (which closed #4312) fixed it for .iloc

Metadata

Metadata

Assignees

No one assigned

    Labels

    Dtype 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