Skip to content
Merged
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ Other Deprecations
- Deprecated allowing ``fill_value`` that cannot be held in the original dtype (excepting NA values for integer and bool dtypes) in :meth:`Series.shift` and :meth:`DataFrame.shift` (:issue:`53802`)
- Deprecated backward-compatibility behavior for :meth:`DataFrame.select_dtypes` matching "str" dtype when ``np.object_`` is specified (:issue:`61916`)
- Deprecated option "future.no_silent_downcasting", as it is no longer used. In a future version accessing this option will raise (:issue:`59502`)
- Deprecated passing non-Index types to :meth:`Index.join`; explicitly convert to Index first (:issue:`62897`)
- Deprecated silent casting of non-datetime 'other' to datetime in :meth:`Series.combine_first` (:issue:`62931`)
- Deprecated slicing on a :class:`Series` or :class:`DataFrame` with a :class:`DatetimeIndex` using a ``datetime.date`` object, explicitly cast to :class:`Timestamp` instead (:issue:`35830`)
- Deprecated the 'inplace' keyword from :meth:`Resampler.interpolate`, as passing ``True`` raises ``AttributeError`` (:issue:`58690`)
Expand Down
10 changes: 10 additions & 0 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
from pandas.errors import (
DuplicateLabelError,
InvalidIndexError,
Pandas4Warning,
)
from pandas.util._decorators import (
Appender,
Expand Down Expand Up @@ -4426,6 +4427,15 @@ def join(
(Index([1, 2, 3, 4, 5, 6], dtype='int64'),
array([ 0, 1, 2, -1, -1, -1]), array([-1, -1, -1, 0, 1, 2]))
"""
if not isinstance(other, Index):
warnings.warn(
f"Passing {type(other).__name__} to {type(self).__name__}.join "
"is deprecated and will raise in a future version. "
"Pass an Index instead.",
Pandas4Warning,
stacklevel=find_stack_level(),
)

other = ensure_index(other)
sort = sort or how == "outer"

Expand Down
11 changes: 11 additions & 0 deletions pandas/tests/indexes/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import pytest

from pandas.compat import IS64
from pandas.errors import Pandas4Warning

from pandas.core.dtypes.common import (
is_integer_dtype,
Expand Down Expand Up @@ -523,3 +524,13 @@ def test_to_frame_name_tuple_multiindex():
result = idx.to_frame(name=(1, 2))
expected = pd.DataFrame([1], columns=MultiIndex.from_arrays([[1], [2]]), index=idx)
tm.assert_frame_equal(result, expected)


def test_join_series_deprecated():
# GH#62897
idx = pd.Index([1, 2])
ser = pd.Series([1, 2, 2])
with tm.assert_produces_warning(
Pandas4Warning, match="Passing .* to .* is deprecated"
):
idx.join(ser)
Loading