Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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.3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,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
15 changes: 15 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,18 @@ 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"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pandas/tests/reshape/concat/test_concat.py:645:10: PDF019 found both 'pd.DataFrame' and 'DataFrame' in the same file
pandas/tests/reshape/concat/test_concat.py:646:11: PDF019 found both 'pd.DataFrame' and 'DataFrame' in the same file


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):
result = concat([df, df2], axis=0)
expected = DataFrame([[1, 2, 3], [4, 5, 6]], index=["a", "b"])
tm.assert_frame_equal(result, expected)