10000 DEPR: Deprecated passing arguments as positional in pd.concat by tegardp · Pull Request #41718 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

DEPR: Deprecated passing arguments as positional in pd.concat #41718

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

Merged
merged 20 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
CLN: Deprecate non-keyword arguments in concat #41485
  • Loading branch information
tegardp committed May 29, 2021
commit 717fd398b96d617952ff259aca480c3584136261
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