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

BUG: Index.join with different names doesn't return None name #57074

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ Performance improvements

Bug fixes
~~~~~~~~~
- Fixed bug in :meth:`DataFrame.join` inconsistently setting result index name (:issue:`55815`)
- Fixed bug in :meth:`Series.diff` allowing non-integer values for the ``periods`` argument. (:issue:`56607`)
lukemanley marked this conversation as resolved.
Show resolved Hide resolved
-

Categorical
^^^^^^^^^^^
Expand Down Expand Up @@ -197,8 +194,8 @@ Groupby/resample/rolling

Reshaping
^^^^^^^^^
-
-
- Bug in :meth:`DataFrame.join` inconsistently setting result index name (:issue:`55815`)
- Bug in :meth:`Index.join` where different :class:`Index` with different ``name`` s would not return an :class:`Index` with ``name=None`` (:issue:`57065`)

Sparse
^^^^^^
Expand All @@ -218,6 +215,8 @@ Styler
Other
^^^^^
- Bug in :meth:`DataFrame.where` where using a non-bool type array in the function would return a ``ValueError`` instead of a ``TypeError`` (:issue:`56330`)
- Bug in :meth:`Series.diff` allowing non-integer values for the ``periods`` argument. (:issue:`56607`)



.. ***DO NOT USE THIS SECTION***
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4834,6 +4834,8 @@ def _join_non_unique(
else:
join_index = self.take(left_idx)

join_index.name = ops.get_op_result_name(self, other)

if how == "outer":
mask = left_idx == -1
if mask.any():
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/indexes/numeric/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,12 @@ def test_join_outer(self, index_large):
tm.assert_index_equal(res, eres)
tm.assert_numpy_array_equal(lidx, elidx)
tm.assert_numpy_array_equal(ridx, eridx)


def test_join_differing_names_none():
# GH 57065
idx1 = Index([1, 1, 2, 3, 4, 4], name="a")
idx2 = Index([2, 5, 3, 4], name="b")
result = idx1.join(idx2)
expected = Index([1, 1, 2, 3, 4, 4])
tm.assert_index_equal(result, expected)
Loading