From 57c23cdf6fd7e6c45b458ef1f5d66b85e52891d0 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Thu, 5 Dec 2019 12:05:10 -0800 Subject: [PATCH] DEPR: join_axes kwarg to pd.concat --- doc/source/whatsnew/v1.0.0.rst | 1 + pandas/core/reshape/concat.py | 43 +++-------------------------- pandas/tests/reshape/test_concat.py | 19 ------------- 3 files changed, 5 insertions(+), 58 deletions(-) diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index 4ce4c12483b36..085f11f63aea2 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -523,6 +523,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more. - Removed the previously deprecated ``time_rule`` keyword from (non-public) :func:`offsets.generate_range`, which has been moved to :func:`core.arrays._ranges.generate_range` (:issue:`24157`) - :meth:`DataFrame.loc` or :meth:`Series.loc` with listlike indexers and missing labels will no longer reindex (:issue:`17295`) - :meth:`DataFrame.to_excel` and :meth:`Series.to_excel` with non-existent columns will no longer reindex (:issue:`17295`) +- :func:`concat` parameter "join_axes" has been removed, use ``reindex_like`` on the result instead (:issue:`22318`) - Removed the previously deprecated "by" keyword from :meth:`DataFrame.sort_index`, use :meth:`DataFrame.sort_values` instead (:issue:`10726`) - Removed support for nested renaming in :meth:`DataFrame.aggregate`, :meth:`Series.aggregate`, :meth:`DataFrameGroupBy.aggregate`, :meth:`SeriesGroupBy.aggregate`, :meth:`Rolling.aggregate` (:issue:`18529`) - Passing ``datetime64`` data to :class:`TimedeltaIndex` or ``timedelta64`` data to ``DatetimeIndex`` now raises ``TypeError`` (:issue:`23539`, :issue:`23937`) diff --git a/pandas/core/reshape/concat.py b/pandas/core/reshape/concat.py index 853a638bdb277..8319db9f07ad8 100644 --- a/pandas/core/reshape/concat.py +++ b/pandas/core/reshape/concat.py @@ -3,7 +3,6 @@ """ from typing import List -import warnings import numpy as np @@ -31,7 +30,6 @@ def concat( objs, axis=0, join: str = "outer", - join_axes=None, ignore_index: bool = False, keys=None, levels=None, @@ -59,12 +57,6 @@ def concat( The axis to concatenate along. join : {'inner', 'outer'}, default 'outer' How to handle indexes on other axis (or axes). - join_axes : list of Index objects - .. deprecated:: 0.25.0 - - Specific indexes to use for the other n - 1 axes instead of performing - inner/outer set logic. Use .reindex() before or after concatenation - as a replacement. ignore_index : bool, default False If True, do not use the index values along the concatenation axis. The resulting axis will be labeled 0, ..., n - 1. This is useful if you are @@ -243,7 +235,6 @@ def concat( axis=axis, ignore_index=ignore_index, join=join, - join_axes=join_axes, keys=keys, levels=levels, names=names, @@ -265,7 +256,6 @@ def __init__( objs, axis=0, join: str = "outer", - join_axes=None, keys=None, levels=None, names=None, @@ -412,7 +402,6 @@ def __init__( # note: this is the BlockManager axis (since DataFrame is transposed) self.axis = axis - self.join_axes = join_axes self.keys = keys self.names = names or getattr(keys, "names", None) self.levels = levels @@ -487,34 +476,10 @@ def _get_new_axes(self): ndim = self._get_result_dim() new_axes = [None] * ndim - if self.join_axes is None: - for i in range(ndim): - if i == self.axis: - continue - new_axes[i] = self._get_comb_axis(i) - - else: - # GH 21951 - warnings.warn( - "The join_axes-keyword is deprecated. Use .reindex or " - ".reindex_like on the result to achieve the same " - "functionality.", - FutureWarning, - stacklevel=4, - ) - - if len(self.join_axes) != ndim - 1: - raise AssertionError( - "length of join_axes must be equal " - "to {length}".format(length=ndim - 1) - ) - - # ufff... - indices = list(range(ndim)) - indices.remove(self.axis) - - for i, ax in zip(indices, self.join_axes): - new_axes[i] = ax + for i in range(ndim): + if i == self.axis: + continue + new_axes[i] = self._get_comb_axis(i) new_axes[self.axis] = self._get_concat_axis() return new_axes diff --git a/pandas/tests/reshape/test_concat.py b/pandas/tests/reshape/test_concat.py index 63f1ef7595f31..ff52c4a5793bf 100644 --- a/pandas/tests/reshape/test_concat.py +++ b/pandas/tests/reshape/test_concat.py @@ -757,25 +757,6 @@ def test_concat_categorical_empty(self): tm.assert_series_equal(pd.concat([s2, s1], ignore_index=True), exp) tm.assert_series_equal(s2.append(s1, ignore_index=True), exp) - def test_concat_join_axes_deprecated(self, axis): - # GH21951 - one = pd.DataFrame([[0.0, 1.0], [2.0, 3.0]], columns=list("ab")) - two = pd.DataFrame( - [[10.0, 11.0], [12.0, 13.0]], index=[1, 2], columns=list("bc") - ) - - expected = pd.concat([one, two], axis=1, sort=False).reindex(index=two.index) - with tm.assert_produces_warning(FutureWarning): - result = pd.concat([one, two], axis=1, sort=False, join_axes=[two.index]) - tm.assert_frame_equal(result, expected) - - expected = pd.concat([one, two], axis=0, sort=False).reindex( - columns=two.columns - ) - with tm.assert_produces_warning(FutureWarning): - result = pd.concat([one, two], axis=0, sort=False, join_axes=[two.columns]) - tm.assert_frame_equal(result, expected) - class TestAppend: def test_append(self, sort, float_frame):