Skip to content

Commit

Permalink
CLN: Deprecate non-keyword arguments in concat pandas-dev#41485
Browse files Browse the repository at this point in the history
  • Loading branch information
tegardp committed May 29, 2021
1 parent 9a1c6a1 commit 717fd39
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ Deprecations
- Deprecated passing arguments as positional (other than ``filepath_or_buffer``) in :func:`read_csv` (:issue:`41485`)
- Deprecated passing arguments as positional in :meth:`DataFrame.drop` (other than ``"labels"``) and :meth:`Series.drop` (:issue:`41485`)
- Deprecated passing arguments as positional (other than ``filepath_or_buffer``) in :func:`read_table` (:issue:`41485`)
- Deprecated passing arguments as positional (other than ``objs``) in :func:`concat` (:issue:`41485`)


.. _whatsnew_130.deprecations.nuisance_columns:
Expand Down
6 changes: 5 additions & 1 deletion pandas/core/reshape/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
import numpy as np

from pandas._typing import FrameOrSeriesUnion
from pandas.util._decorators import cache_readonly
from pandas.util._decorators import (
cache_readonly,
deprecate_nonkeyword_arguments,
)

from pandas.core.dtypes.concat import concat_compat
from pandas.core.dtypes.generic import (
Expand Down Expand Up @@ -52,6 +55,7 @@
# Concatenate DataFrame objects


@deprecate_nonkeyword_arguments(version=None, allowed_args=["objs"])
@overload
def concat(
objs: Iterable[DataFrame] | Mapping[Hashable, DataFrame],
Expand Down
17 changes: 17 additions & 0 deletions pandas/tests/reshape/concat/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,3 +638,20 @@ def test_concat_multiindex_with_empty_rangeindex():
result = concat([df1, df2])
expected = DataFrame([[1, 2], [np.nan, np.nan]], columns=mi)
tm.assert_frame_equal(result, expected)


def test_concat_posargs_deprecation(all_parsers):
# https://github.com/pandas-dev/pandas/issues/41485
df = pd.DataFrame([[1,2,3]], index=["a"])
df2 = pd.DataFrame([[4,5,6]], index=["b"])

msg = (
"In a future version of pandas all arguments of concat"
"except for the argument 'objs' will be keyword-only"
)
with tm.assert_produces_warning(FutureWarning, match=msg):
concat([df, df2], " ")
expected = DataFrame([[1,2,3],[4,5,6]], index=["a","b"])
tm.assert_frame_equal(result, expected)


0 comments on commit 717fd39

Please sign in to comment.