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

DEPR: join_axes kwarg to pd.concat #30090

Merged
merged 1 commit into from
Dec 5, 2019
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/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
43 changes: 4 additions & 39 deletions pandas/core/reshape/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

from typing import List
import warnings

import numpy as np

Expand Down Expand Up @@ -31,7 +30,6 @@ def concat(
objs,
axis=0,
join: str = "outer",
join_axes=None,
ignore_index: bool = False,
keys=None,
levels=None,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -243,7 +235,6 @@ def concat(
axis=axis,
ignore_index=ignore_index,
join=join,
join_axes=join_axes,
keys=keys,
levels=levels,
names=names,
Expand All @@ -265,7 +256,6 @@ def __init__(
objs,
axis=0,
join: str = "outer",
join_axes=None,
keys=None,
levels=None,
names=None,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 0 additions & 19 deletions pandas/tests/reshape/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down