-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
API / CoW: constructing DataFrame from DataFrame creates lazy copy #50499
Conversation
# Conflicts: # pandas/core/generic.py
# Conflicts: # pandas/core/generic.py
@@ -951,6 +951,10 @@ Indexing | |||
- Bug in :class:`BusinessHour` would cause creation of :class:`DatetimeIndex` to fail when no opening hour was included in the index (:issue:`49835`) | |||
- | |||
|
|||
Copy on write | |||
^^^^^^^^^^^^^ | |||
- Bug in :class:`DataFrame` constructor not tracking reference if called with another :class:`DataFrame` (:issue:`50499`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the equivalent Series change I listed this in the "Copy-on-Write improvements" section instead of seeing it as a bug fix (it was a known gap left out of the initial implementation, and it also changes behaviour, so at this stage I wouldn't yet label it as a bug fix)
@@ -205,6 +205,7 @@ | |||
to_arrays, | |||
treat_as_nested, | |||
) | |||
from pandas.core.internals.managers import using_copy_on_write |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import can now be removed (after a merge with main)
and new_data is self._mgr | ||
or not copy | ||
and using_copy_on_write() | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain a bit how this change is related? We are passing here a Manager object to the constructor, I suppose, and you only changed the constructor when it receives a DataFrame?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, this is unrelated to the constructor change, I'll make a separate pr.
Currently, when reindexing with copy=False we don't track references, causing problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also have some skips in #50536 related to reindex
, there are several things not yet fully working it seems
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.cc @jorisvandenbossche