Skip to content

Correct place for SettingWithCopyWarning? #5650

Closed
@michaelaye

Description

@michaelaye

I am really happy about the SettingWithCopyWarning but is this situation the right place to pop up? Because what I want to do seems to work, maybe I don't see the danger of a possible case?

In [19]: df.convert_objects().dtypes
Out[19]: 
hour      float64
minute    float64
second    float64
tb        float64
dtype: object

In [20]: df['hour'] = df.hour.astype('int')
-c:1: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_index,col_indexer] = value instead

In [21]: df.dtypes
Out[21]: 
hour        int64
minute    float64
second    float64
tb        float64
dtype: object

using master.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions