Skip to content

ENH: switch to copy=False by default when DataFrame is constructed from dict of Series/Index for CoW #52967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 of 3 tasks
phofl opened this issue Apr 27, 2023 · 2 comments
Labels
Constructors Series/DataFrame/Index/pd.array Constructors Copy / view semantics Enhancement Needs Discussion Requires discussion from core team before further action
Milestone

Comments

@phofl
Copy link
Member

phofl commented Apr 27, 2023

Feature Type

  • Adding new functionality to pandas
  • Changing existing functionality in pandas
  • Removing existing functionality in pandas

Problem Description

This would make stuff faster and CoW avoids that we mutate more than one object at once.

We should still copy arrays when they are part of the dictionary.

cc @jorisvandenbossche thoughts?

Feature Description

See above

Alternative Solutions

Continue copying

Additional Context

No response

@phofl phofl added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member Copy / view semantics labels Apr 27, 2023
@jorisvandenbossche
Copy link
Member

For me that would be fine. As you mention, it shouldn't impact copy/view behaviour since with CoW we still track those columns were created from the Series/Index objects.
I think the main impact is that this will no longer result in a consolidated DataFrame (which I think is the main reason that this has a default of copy=True at the moment)

@jorisvandenbossche jorisvandenbossche added Needs Discussion Requires discussion from core team before further action Constructors Series/DataFrame/Index/pd.array Constructors and removed Needs Triage Issue that has not been reviewed by a pandas team member labels May 2, 2023
@phofl
Copy link
Member Author

phofl commented May 2, 2023

You could still set copy=True manually if this is important I guess? But yeah this is a fair point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Constructors Series/DataFrame/Index/pd.array Constructors Copy / view semantics Enhancement Needs Discussion Requires discussion from core team before further action
Projects
None yet
Development

No branches or pull requests

3 participants