Skip to content

BUG: astype assignment with loc not working #5702

@TomAugspurger

Description

@TomAugspurger
Contributor
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

Activity

jreback

jreback commented on Dec 15, 2013

@jreback
Contributor

@TomAugspurger thanks for the report...was a tad tricky, because normally I don't coerce a float block at all (it can get expensive if you have to nan check it), but only needs coercing if you are exactly replaceing the values (all of them)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Relationships

    None yet

      Development

      Participants

      @jreback@TomAugspurger

      Issue actions

        BUG: astype assignment with loc not working · Issue #5702 · pandas-dev/pandas