Skip to content
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

DOC: Update merge copy parameter code and doc #54077

Closed
wants to merge 2 commits into from

Conversation

liang3zy22
Copy link
Contributor

@liang3zy22 liang3zy22 changed the title DOC: Update merge copy parameter documentation. DOC: Update merge copy parameter documentation Jul 11, 2023
@mroeschke mroeschke added the Docs label Jul 11, 2023
@@ -356,7 +356,8 @@
`right` should be left as-is, with no suffix. At least one of the
values must not be None.
copy : bool, default True
If False, avoid copy if possible.
If False, avoid copy if copy requirements are fulfilled. If copy operation
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this description clarifies when a copy is needed

@liang3zy22 liang3zy22 force-pushed the gh4599 branch 5 times, most recently from 8ec298f to 729ef89 Compare July 18, 2023 03:14
@liang3zy22 liang3zy22 changed the title DOC: Update merge copy parameter documentation DOC: Update merge copy parameter code and doc Jul 18, 2023
@liang3zy22
Copy link
Contributor Author

I have checked merge copy related codes, found that following codes will decide if copy:

pandas/pandas/core/internals/concat.py:229
        if needs_copy and not indexers:
            mgr = mgr.copy()

The needs_copy parameter is defined by user input, CoW status and concat axis.The indexers parameter is defined by following codes:

pandas/pandas/core/reshape/concat.py:666
            for obj in self.objs:
                indexers = {}
                for ax, new_labels in enumerate(self.new_axes):
                    # ::-1 to convert BlockManager ax to DataFrame ax
                    if ax == self.bm_axis:
                        # Suppress reindexing on concat axis
                        continue

                    # 1-ax to convert BlockManager axis to DataFrame axis
                    obj_labels = obj.axes[1 - ax]
                    if not new_labels.equals(obj_labels):
                        indexers[ax] = obj_labels.get_indexer(new_labels)

                mgrs_indexers.append((obj._mgr, indexers))

I don't know why new_labels can be not equal to obj_labels. They are both from objs, although there are some operations in self.new_axes function. I have tried several examples, but can't get an indexers value which is not None.

@liang3zy22 liang3zy22 force-pushed the gh4599 branch 2 times, most recently from 1b1dc15 to 8fedf55 Compare July 19, 2023 03:17
@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

@mroeschke mroeschke closed this Aug 21, 2023
@liang3zy22 liang3zy22 deleted the gh4599 branch February 12, 2024 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Give the merge copy parameter better documentation
2 participants