Skip to content

BUG: MultiIndex.append not checking names for equality #48288

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 6 commits into from
Aug 30, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Aug 28, 2022

  • closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

@phofl
Copy link
Member Author

phofl commented Aug 29, 2022

Added test and also fixed an internal bug in pivot_table creating missmatches in Index names

@mroeschke mroeschke added this to the 1.6 milestone Aug 30, 2022
@mroeschke mroeschke merged commit b1e6c1f into pandas-dev:main Aug 30, 2022
@mroeschke
Copy link
Member

Thanks @phofl

@phofl phofl deleted the append_midx branch August 30, 2022 20:13
@mroeschke mroeschke modified the milestones: 1.6, 2.0 Oct 13, 2022
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
)

* BUG: MultiIndex.append not checking names for equality

* BUG: MultiIndex.append not checking names for equality

* Update doc/source/whatsnew/v1.6.0.rst

Co-authored-by: Matthew Roeschke <[email protected]>

* Add test and fix bug

* Improve name checking

Co-authored-by: Matthew Roeschke <[email protected]>
zhengruifeng pushed a commit to apache/spark that referenced this pull request Sep 5, 2023
### What changes were proposed in this pull request?

This PR proposes to fix the behavior of `MultiIndex.append` to do not checking names.

### Why are the changes needed?

To match the behavior with pandas according to pandas-dev/pandas#48288

### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
Yes, the behavior is changed to match with pandas:

**Testing data**
```python
>>> psmidx1
MultiIndex([('a', 'x', 1),
            ('b', 'y', 2),
            ('c', 'z', 3)],
           names=['x', 'y', 'z'])
>>> psmidx2
MultiIndex([('a', 'x', 1),
            ('b', 'y', 2),
            ('c', 'z', 3)],
           names=['p', 'q', 'r'])
```

**Before**
```python
>>> psmidx1.append(psmidx2)
MultiIndex([('a', 'x', 1),
            ('b', 'y', 2),
            ('c', 'z', 3),
            ('a', 'x', 1),
            ('b', 'y', 2),
            ('c', 'z', 3)],
           names=['x', 'y', 'z'])
```

**After**
```python
>>> psmidx1.append(psmidx2)
MultiIndex([('a', 'x', 1),
            ('b', 'y', 2),
            ('c', 'z', 3),
            ('a', 'x', 1),
            ('b', 'y', 2),
            ('c', 'z', 3)],
           )
```

### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
Fix the existing UTs.

### Was this patch authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this patch, please include the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
If no, write 'No'.
Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
No.

Closes #42787 from itholic/SPARK-43241.

Authored-by: Haejoon Lee <[email protected]>
Signed-off-by: Ruifeng Zheng <[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