Skip to content

ENH: Add inplace argument to pandas.DataFrame.insert #50303

Closed as not planned
Closed as not planned
@bhvieira

Description

@bhvieira

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

Currently, most methods only make in-place alterations when explicitly told to (default is inplace = False). pandas.DataFrame.insert is an exception, working in true OOP-way. There is not even an inplace argument for it.

I don't know if there is any justification for this choice, but I would expect this method to work as the others.

If this is desirable, I can work on this as well.

Feature Description

Add a new inplace parameter for the pandas.DataFrame.insert. Initally, its default will be inplace = True, with a deprecation warning. In a future breaking change, it could be changed to inplace = False

df = df.insert(1, "A", col, inplace=False) 

Alternative Solutions

I'm not aware of an alternative solution, pandas.DataFrame.insert returns None, like other methods with the inplace=True parameter.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions