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 all commits
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
11 changes: 6 additions & 5 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ Performance improvements

Bug fixes
~~~~~~~~~
- Fixed bug in :meth:`DataFrame.join` inconsistently setting result index name (:issue:`55815`)
- Fixed bug in :meth:`DataFrame.to_string` that raised ``StopIteration`` with nested DataFrames. (:issue:`16098`)
- 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 @@ -188,9 +185,11 @@ Numeric

Conversion
^^^^^^^^^^
- Bug in :meth:`DataFrame.to_string` that raised ``StopIteration`` with nested DataFrames. (:issue:`16098`)
- Bug in :meth:`Series.astype` might modify read-only array inplace when casting to a string dtype (:issue:`57212`)
- Bug in :meth:`Series.reindex` not maintaining ``float32`` type when a ``reindex`` introduces a missing value (:issue:`45857`)


Strings
^^^^^^^
- Bug in :meth:`Series.value_counts` would not respect ``sort=False`` for series having ``string`` dtype (:issue:`55224`)
Expand Down Expand Up @@ -243,8 +242,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 @@ -265,6 +264,8 @@ Other
^^^^^
- Bug in :meth:`DataFrame.sort_index` when passing ``axis="columns"`` and ``ignore_index=True`` and ``ascending=False`` not returning a :class:`RangeIndex` columns (:issue:`57293`)
- 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 @@ -4451,6 +4451,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)