Skip to content

Commit 717fd39

Browse files
committed
CLN: Deprecate non-keyword arguments in concat pandas-dev#41485
1 parent 9a1c6a1 commit 717fd39

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

doc/source/whatsnew/v1.3.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ Deprecations
701701
- Deprecated passing arguments as positional (other than ``filepath_or_buffer``) in :func:`read_csv` (:issue:`41485`)
702702
- Deprecated passing arguments as positional in :meth:`DataFrame.drop` (other than ``"labels"``) and :meth:`Series.drop` (:issue:`41485`)
703703
- Deprecated passing arguments as positional (other than ``filepath_or_buffer``) in :func:`read_table` (:issue:`41485`)
704+
- Deprecated passing arguments as positional (other than ``objs``) in :func:`concat` (:issue:`41485`)
704705

705706

706707
.. _whatsnew_130.deprecations.nuisance_columns:

pandas/core/reshape/concat.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
import numpy as np
1717

1818
from pandas._typing import FrameOrSeriesUnion
19-
from pandas.util._decorators import cache_readonly
19+
from pandas.util._decorators import (
20+
cache_readonly,
21+
deprecate_nonkeyword_arguments,
22+
)
2023

2124
from pandas.core.dtypes.concat import concat_compat
2225
from pandas.core.dtypes.generic import (
@@ -52,6 +55,7 @@
5255
# Concatenate DataFrame objects
5356

5457

58+
@deprecate_nonkeyword_arguments(version=None, allowed_args=["objs"])
5559
@overload
5660
def concat(
5761
objs: Iterable[DataFrame] | Mapping[Hashable, DataFrame],

pandas/tests/reshape/concat/test_concat.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,3 +638,20 @@ def test_concat_multiindex_with_empty_rangeindex():
638638
result = concat([df1, df2])
639639
expected = DataFrame([[1, 2], [np.nan, np.nan]], columns=mi)
640640
tm.assert_frame_equal(result, expected)
641+
642+
643+
def test_concat_posargs_deprecation(all_parsers):
644+
# https://github.com/pandas-dev/pandas/issues/41485
645+
df = pd.DataFrame([[1,2,3]], index=["a"])
646+
df2 = pd.DataFrame([[4,5,6]], index=["b"])
647+
648+
msg = (
649+
"In a future version of pandas all arguments of concat"
650+
"except for the argument 'objs' will be keyword-only"
651+
)
652+
with tm.assert_produces_warning(FutureWarning, match=msg):
653+
concat([df, df2], " ")
654+
expected = DataFrame([[1,2,3],[4,5,6]], index=["a","b"])
655+
tm.assert_frame_equal(result, expected)
656+
657+

0 commit comments

Comments
 (0)