Skip to content

ENH: A cheap copy on a dataframe #19102

Closed
@has2k1

Description

@has2k1

With the deprecation, there is no cheap way tell pandas that the user knows that they are modifying a copied dataframe. Libraries that use pandas cannot afford to always copy() after sub-setting. My comment in the PR thread gives a specific example.

If resurrecting is_copy is not an option, then a better solution could be a method that can be applied inline.

df = pd.DataFrame({'A':[1,2,3]})
df2 = df[df.A>2].as_copy()               # New method, as_copy
df2['B'] = 2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions