Skip to content

Commit c2d6c01

Browse files
jbrockmendelproost
authored andcommitted
DEPR: join_axes kwarg to pd.concat (pandas-dev#30090)
1 parent 8027846 commit c2d6c01

File tree

3 files changed

+5
-58
lines changed

3 files changed

+5
-58
lines changed

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
541541
- 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`)
542542
- :meth:`DataFrame.loc` or :meth:`Series.loc` with listlike indexers and missing labels will no longer reindex (:issue:`17295`)
543543
- :meth:`DataFrame.to_excel` and :meth:`Series.to_excel` with non-existent columns will no longer reindex (:issue:`17295`)
544+
- :func:`concat` parameter "join_axes" has been removed, use ``reindex_like`` on the result instead (:issue:`22318`)
544545
- Removed the previously deprecated "by" keyword from :meth:`DataFrame.sort_index`, use :meth:`DataFrame.sort_values` instead (:issue:`10726`)
545546
- Removed support for nested renaming in :meth:`DataFrame.aggregate`, :meth:`Series.aggregate`, :meth:`DataFrameGroupBy.aggregate`, :meth:`SeriesGroupBy.aggregate`, :meth:`Rolling.aggregate` (:issue:`18529`)
546547
- Passing ``datetime64`` data to :class:`TimedeltaIndex` or ``timedelta64`` data to ``DatetimeIndex`` now raises ``TypeError`` (:issue:`23539`, :issue:`23937`)

pandas/core/reshape/concat.py

+4-39
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44

55
from typing import List
6-
import warnings
76

87
import numpy as np
98

@@ -31,7 +30,6 @@ def concat(
3130
objs,
3231
axis=0,
3332
join: str = "outer",
34-
join_axes=None,
3533
ignore_index: bool = False,
3634
keys=None,
3735
levels=None,
@@ -59,12 +57,6 @@ def concat(
5957
The axis to concatenate along.
6058
join : {'inner', 'outer'}, default 'outer'
6159
How to handle indexes on other axis (or axes).
62-
join_axes : list of Index objects
63-
.. deprecated:: 0.25.0
64-
65-
Specific indexes to use for the other n - 1 axes instead of performing
66-
inner/outer set logic. Use .reindex() before or after concatenation
67-
as a replacement.
6860
ignore_index : bool, default False
6961
If True, do not use the index values along the concatenation axis. The
7062
resulting axis will be labeled 0, ..., n - 1. This is useful if you are
@@ -243,7 +235,6 @@ def concat(
243235
axis=axis,
244236
ignore_index=ignore_index,
245237
join=join,
246-
join_axes=join_axes,
247238
keys=keys,
248239
levels=levels,
249240
names=names,
@@ -265,7 +256,6 @@ def __init__(
265256
objs,
266257
axis=0,
267258
join: str = "outer",
268-
join_axes=None,
269259
keys=None,
270260
levels=None,
271261
names=None,
@@ -412,7 +402,6 @@ def __init__(
412402

413403
# note: this is the BlockManager axis (since DataFrame is transposed)
414404
self.axis = axis
415-
self.join_axes = join_axes
416405
self.keys = keys
417406
self.names = names or getattr(keys, "names", None)
418407
self.levels = levels
@@ -487,34 +476,10 @@ def _get_new_axes(self):
487476
ndim = self._get_result_dim()
488477
new_axes = [None] * ndim
489478

490-
if self.join_axes is None:
491-
for i in range(ndim):
492-
if i == self.axis:
493-
continue
494-
new_axes[i] = self._get_comb_axis(i)
495-
496-
else:
497-
# GH 21951
498-
warnings.warn(
499-
"The join_axes-keyword is deprecated. Use .reindex or "
500-
".reindex_like on the result to achieve the same "
501-
"functionality.",
502-
FutureWarning,
503-
stacklevel=4,
504-
)
505-
506-
if len(self.join_axes) != ndim - 1:
507-
raise AssertionError(
508-
"length of join_axes must be equal "
509-
"to {length}".format(length=ndim - 1)
510-
)
511-
512-
# ufff...
513-
indices = list(range(ndim))
514-
indices.remove(self.axis)
515-
516-
for i, ax in zip(indices, self.join_axes):
517-
new_axes[i] = ax
479+
for i in range(ndim):
480+
if i == self.axis:
481+
continue
482+
new_axes[i] = self._get_comb_axis(i)
518483

519484
new_axes[self.axis] = self._get_concat_axis()
520485
return new_axes

pandas/tests/reshape/test_concat.py

-19
Original file line numberDiff line numberDiff line change
@@ -758,25 +758,6 @@ def test_concat_categorical_empty(self):
758758
tm.assert_series_equal(pd.concat([s2, s1], ignore_index=True), exp)
759759
tm.assert_series_equal(s2.append(s1, ignore_index=True), exp)
760760

761-
def test_concat_join_axes_deprecated(self, axis):
762-
# GH21951
763-
one = pd.DataFrame([[0.0, 1.0], [2.0, 3.0]], columns=list("ab"))
764-
two = pd.DataFrame(
765-
[[10.0, 11.0], [12.0, 13.0]], index=[1, 2], columns=list("bc")
766-
)
767-
768-
expected = pd.concat([one, two], axis=1, sort=False).reindex(index=two.index)
769-
with tm.assert_produces_warning(FutureWarning):
770-
result = pd.concat([one, two], axis=1, sort=False, join_axes=[two.index])
771-
tm.assert_frame_equal(result, expected)
772-
773-
expected = pd.concat([one, two], axis=0, sort=False).reindex(
774-
columns=two.columns
775-
)
776-
with tm.assert_produces_warning(FutureWarning):
777-
result = pd.concat([one, two], axis=0, sort=False, join_axes=[two.columns])
778-
tm.assert_frame_equal(result, expected)
779-
780761

781762
class TestAppend:
782763
def test_append(self, sort, float_frame):

0 commit comments

Comments
 (0)