Skip to content

DOC: Adjust user guide for CoW docs #55337

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

Merged
merged 5 commits into from
Oct 15, 2023
Merged

DOC: Adjust user guide for CoW docs #55337

merged 5 commits into from
Oct 15, 2023

Conversation

phofl
Copy link
Member

@phofl phofl commented Sep 30, 2023

This is mostly from my blog post, would like to backport this ideally.

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's some nice content to add to the docs! Added a few small comments

df = pd.DataFrame({"a": [1, 2], "b": [1.5, 2.5]})
df.to_numpy()

The array shares data with the DataFrame if the DataFrame consists of only one NumPy array:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also mention Series here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

arr = df.to_numpy()
arr.flags.writeable = True
arr[0, 0] = 100
arr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe show df here as well, to show it was updated? Or do we actually not want to show that (since users shouldn't rely on that happening)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'd prefer not to show this, this example is meant for users that don't care about df anymore

df.iloc[0, 0] = 100

No copy is necessary in this example.
Creating multiple references in the same method keeps unnecessary references alive
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the "in the same method" here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should go away, thx

@phofl phofl merged commit 7b8c6f6 into pandas-dev:main Oct 15, 2023
@phofl phofl deleted the doc_cow branch October 15, 2023 13:44
meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Oct 15, 2023
phofl added a commit that referenced this pull request Oct 15, 2023
…cs) (#55532)

Backport PR #55337: DOC: Adjust user guide for CoW docs

Co-authored-by: Patrick Hoefler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants