From 2e18f91cd239279c6eb8601bdbcabfdc93f29206 Mon Sep 17 00:00:00 2001 From: tegardp Date: Sat, 29 May 2021 13:35:39 +0700 Subject: [PATCH 01/17] CLN: Deprecate non-keyword arguments in read_table #41485 --- doc/source/whatsnew/v1.3.0.rst | 2 +- pandas/io/parsers/readers.py | 4 +++- pandas/tests/io/parser/common/test_common_basic.py | 11 +++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index ea9017da8a2f9..38682d188e57a 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -700,7 +700,7 @@ Deprecations - Deprecated passing arguments as positional in :meth:`DataFrame.where` and :meth:`Series.where` (other than ``"cond"`` and ``"other"``) (:issue:`41485`) - 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`) .. _whatsnew_130.deprecations.nuisance_columns: diff --git a/pandas/io/parsers/readers.py b/pandas/io/parsers/readers.py index 8bf1ab1260b8e..aa2898f1fb1fb 100644 --- a/pandas/io/parsers/readers.py +++ b/pandas/io/parsers/readers.py @@ -591,7 +591,9 @@ def read_csv( return _read(filepath_or_buffer, kwds) - +@deprecate_nonkeyword_arguments( + version=None, allowed_args=["filepath_or_buffer"], stacklevel=3 +) @Appender( _doc_read_csv_and_table.format( func_name="read_table", diff --git a/pandas/tests/io/parser/common/test_common_basic.py b/pandas/tests/io/parser/common/test_common_basic.py index 97b3be1306cd5..aeec69470dbf9 100644 --- a/pandas/tests/io/parser/common/test_common_basic.py +++ b/pandas/tests/io/parser/common/test_common_basic.py @@ -823,3 +823,14 @@ def test_malformed_second_line(all_parsers): result = parser.read_csv(StringIO(data), skip_blank_lines=False, header=1) expected = DataFrame({"a": ["b"]}) tm.assert_frame_equal(result, expected) + +def test_read_table_posargs_deprecation(all_parsers): + # https://github.com/pandas-dev/pandas/issues/41485 + f = StringIO("a\tb\n1\t2") + parser = all_parsers + msg = ( + "In a future version of pandas all arguments of read_table " + "except for the argument 'filepath_or_buffer' will be keyword-only" + ) + with tm.assert_produces_warning(FutureWarning, match=msg): + parser.read_table(f, " ") From 9a1c6a1f96e6726ddb069598f043c00878fc1098 Mon Sep 17 00:00:00 2001 From: tegardp Date: Sat, 29 May 2021 13:47:01 +0700 Subject: [PATCH 02/17] CLN: Deprecate non-keyword arguments in read_table #41485 --- pandas/io/parsers/readers.py | 1 + pandas/tests/io/parser/common/test_common_basic.py | 1 + 2 files changed, 2 insertions(+) diff --git a/pandas/io/parsers/readers.py b/pandas/io/parsers/readers.py index aa2898f1fb1fb..a384846b7a063 100644 --- a/pandas/io/parsers/readers.py +++ b/pandas/io/parsers/readers.py @@ -591,6 +591,7 @@ def read_csv( return _read(filepath_or_buffer, kwds) + @deprecate_nonkeyword_arguments( version=None, allowed_args=["filepath_or_buffer"], stacklevel=3 ) diff --git a/pandas/tests/io/parser/common/test_common_basic.py b/pandas/tests/io/parser/common/test_common_basic.py index aeec69470dbf9..2be7663a8c1a4 100644 --- a/pandas/tests/io/parser/common/test_common_basic.py +++ b/pandas/tests/io/parser/common/test_common_basic.py @@ -824,6 +824,7 @@ def test_malformed_second_line(all_parsers): expected = DataFrame({"a": ["b"]}) tm.assert_frame_equal(result, expected) + def test_read_table_posargs_deprecation(all_parsers): # https://github.com/pandas-dev/pandas/issues/41485 f = StringIO("a\tb\n1\t2") From 717fd398b96d617952ff259aca480c3584136261 Mon Sep 17 00:00:00 2001 From: tegardp Date: Sat, 29 May 2021 14:19:11 +0700 Subject: [PATCH 03/17] CLN: Deprecate non-keyword arguments in concat #41485 --- doc/source/whatsnew/v1.3.0.rst | 1 + pandas/core/reshape/concat.py | 6 +++++- pandas/tests/reshape/concat/test_concat.py | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 38682d188e57a..574f089450998 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -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: diff --git a/pandas/core/reshape/concat.py b/pandas/core/reshape/concat.py index b3b453ea6355a..804418d3c4d89 100644 --- a/pandas/core/reshape/concat.py +++ b/pandas/core/reshape/concat.py @@ -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 ( @@ -52,6 +55,7 @@ # Concatenate DataFrame objects +@deprecate_nonkeyword_arguments(version=None, allowed_args=["objs"]) @overload def concat( objs: Iterable[DataFrame] | Mapping[Hashable, DataFrame], diff --git a/pandas/tests/reshape/concat/test_concat.py b/pandas/tests/reshape/concat/test_concat.py index 96b88dc61cfed..57b0462710bc5 100644 --- a/pandas/tests/reshape/concat/test_concat.py +++ b/pandas/tests/reshape/concat/test_concat.py @@ -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) + + From 768c521eb29b9f9994c9c38096bfd4ac2a4cdc80 Mon Sep 17 00:00:00 2001 From: tegardp Date: Sat, 29 May 2021 14:22:12 +0700 Subject: [PATCH 04/17] CLN: Deprecate non-keyword arguments in concat #41485 --- pandas/tests/reshape/concat/test_concat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/reshape/concat/test_concat.py b/pandas/tests/reshape/concat/test_concat.py index 57b0462710bc5..5fe80e5d9ed22 100644 --- a/pandas/tests/reshape/concat/test_concat.py +++ b/pandas/tests/reshape/concat/test_concat.py @@ -650,7 +650,7 @@ def test_concat_posargs_deprecation(all_parsers): "except for the argument 'objs' will be keyword-only" ) with tm.assert_produces_warning(FutureWarning, match=msg): - concat([df, df2], " ") + result = concat([df, df2], " ") expected = DataFrame([[1,2,3],[4,5,6]], index=["a","b"]) tm.assert_frame_equal(result, expected) From 6d0ae9c38def818658ea8a7875d11d22b303a5bd Mon Sep 17 00:00:00 2001 From: tegardp Date: Sat, 29 May 2021 14:27:06 +0700 Subject: [PATCH 05/17] CLN: Deprecate non-keyword arguments in concat #41485 --- pandas/tests/reshape/concat/test_concat.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pandas/tests/reshape/concat/test_concat.py b/pandas/tests/reshape/concat/test_concat.py index 5fe80e5d9ed22..1d870ff88a873 100644 --- a/pandas/tests/reshape/concat/test_concat.py +++ b/pandas/tests/reshape/concat/test_concat.py @@ -642,16 +642,15 @@ def test_concat_multiindex_with_empty_rangeindex(): 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"]) + 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): - result = concat([df, df2], " ") - expected = DataFrame([[1,2,3],[4,5,6]], index=["a","b"]) + result = concat([df, df2], " ") + expected = DataFrame([[1, 2, 3],[4, 5, 6]], index=["a", "b"]) tm.assert_frame_equal(result, expected) - From 05df736b44fd878b0336075261fef4e7853122b3 Mon Sep 17 00:00:00 2001 From: tegardp Date: Sat, 29 May 2021 21:28:54 +0700 Subject: [PATCH 06/17] fixing pep8 --- pandas/tests/reshape/concat/test_concat.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pandas/tests/reshape/concat/test_concat.py b/pandas/tests/reshape/concat/test_concat.py index 1d870ff88a873..f94cb87f09495 100644 --- a/pandas/tests/reshape/concat/test_concat.py +++ b/pandas/tests/reshape/concat/test_concat.py @@ -651,6 +651,5 @@ def test_concat_posargs_deprecation(all_parsers): ) with tm.assert_produces_warning(FutureWarning, match=msg): result = concat([df, df2], " ") - expected = DataFrame([[1, 2, 3],[4, 5, 6]], index=["a", "b"]) - tm.assert_frame_equal(result, expected) - + expected = DataFrame([[1, 2, 3], [4, 5, 6]], index=["a", "b"]) + tm.assert_frame_equal(result, expected) \ No newline at end of file From a12db6b2244d1884e57e7f4ffa83cc78599dbfdb Mon Sep 17 00:00:00 2001 From: tegardp Date: Sat, 29 May 2021 21:29:52 +0700 Subject: [PATCH 07/17] fixing pep8 --- pandas/tests/reshape/concat/test_concat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/reshape/concat/test_concat.py b/pandas/tests/reshape/concat/test_concat.py index f94cb87f09495..286ca1a75fd6f 100644 --- a/pandas/tests/reshape/concat/test_concat.py +++ b/pandas/tests/reshape/concat/test_concat.py @@ -652,4 +652,4 @@ def test_concat_posargs_deprecation(all_parsers): with tm.assert_produces_warning(FutureWarning, match=msg): result = concat([df, df2], " ") expected = DataFrame([[1, 2, 3], [4, 5, 6]], index=["a", "b"]) - tm.assert_frame_equal(result, expected) \ No newline at end of file + tm.assert_frame_equal(result, expected) From 59e02844c2eef41326a898e5889e55626fdedd20 Mon Sep 17 00:00:00 2001 From: tegardp Date: Sat, 29 May 2021 22:26:29 +0700 Subject: [PATCH 08/17] fix axis parameter --- pandas/tests/reshape/concat/test_concat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/reshape/concat/test_concat.py b/pandas/tests/reshape/concat/test_concat.py index 286ca1a75fd6f..17fc3d0817b28 100644 --- a/pandas/tests/reshape/concat/test_concat.py +++ b/pandas/tests/reshape/concat/test_concat.py @@ -650,6 +650,6 @@ def test_concat_posargs_deprecation(all_parsers): "except for the argument 'objs' will be keyword-only" ) with tm.assert_produces_warning(FutureWarning, match=msg): - result = concat([df, df2], " ") + result = concat([df, df2], axis=0) expected = DataFrame([[1, 2, 3], [4, 5, 6]], index=["a", "b"]) tm.assert_frame_equal(result, expected) From fd962401f43b341d738b5cdd3cf091cecd4c5d3c Mon Sep 17 00:00:00 2001 From: tegardp Date: Sat, 29 May 2021 22:33:53 +0700 Subject: [PATCH 09/17] renaming single character variable --- pandas/tests/io/parser/common/test_common_basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/io/parser/common/test_common_basic.py b/pandas/tests/io/parser/common/test_common_basic.py index 2be7663a8c1a4..8fa2d7f7b8d65 100644 --- a/pandas/tests/io/parser/common/test_common_basic.py +++ b/pandas/tests/io/parser/common/test_common_basic.py @@ -827,11 +827,11 @@ def test_malformed_second_line(all_parsers): def test_read_table_posargs_deprecation(all_parsers): # https://github.com/pandas-dev/pandas/issues/41485 - f = StringIO("a\tb\n1\t2") + data = StringIO("a\tb\n1\t2") parser = all_parsers msg = ( "In a future version of pandas all arguments of read_table " "except for the argument 'filepath_or_buffer' will be keyword-only" ) with tm.assert_produces_warning(FutureWarning, match=msg): - parser.read_table(f, " ") + parser.read_table(data, " ") From 1ee4805126195f672fa60952d1e131cb76ab19b3 Mon Sep 17 00:00:00 2001 From: tegardp Date: Sun, 30 May 2021 12:23:20 +0700 Subject: [PATCH 10/17] Revert "renaming single character variable" This reverts commit fd962401f43b341d738b5cdd3cf091cecd4c5d3c. --- pandas/tests/io/parser/common/test_common_basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/io/parser/common/test_common_basic.py b/pandas/tests/io/parser/common/test_common_basic.py index 8fa2d7f7b8d65..2be7663a8c1a4 100644 --- a/pandas/tests/io/parser/common/test_common_basic.py +++ b/pandas/tests/io/parser/common/test_common_basic.py @@ -827,11 +827,11 @@ def test_malformed_second_line(all_parsers): def test_read_table_posargs_deprecation(all_parsers): # https://github.com/pandas-dev/pandas/issues/41485 - data = StringIO("a\tb\n1\t2") + f = StringIO("a\tb\n1\t2") parser = all_parsers msg = ( "In a future version of pandas all arguments of read_table " "except for the argument 'filepath_or_buffer' will be keyword-only" ) with tm.assert_produces_warning(FutureWarning, match=msg): - parser.read_table(data, " ") + parser.read_table(f, " ") From e29757a0eb6fd3d57ab151f4d783fcbcb9f2048e Mon Sep 17 00:00:00 2001 From: Tegar D Pratama Date: Thu, 3 Jun 2021 19:31:17 +0700 Subject: [PATCH 11/17] fix test --- pandas/tests/reshape/concat/test_concat.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/tests/reshape/concat/test_concat.py b/pandas/tests/reshape/concat/test_concat.py index 17fc3d0817b28..64c34240cd962 100644 --- a/pandas/tests/reshape/concat/test_concat.py +++ b/pandas/tests/reshape/concat/test_concat.py @@ -640,10 +640,10 @@ def test_concat_multiindex_with_empty_rangeindex(): tm.assert_frame_equal(result, expected) -def test_concat_posargs_deprecation(all_parsers): +def test_concat_posargs_deprecation(): # https://github.com/pandas-dev/pandas/issues/41485 - df = pd.DataFrame([[1, 2, 3]], index=["a"]) - df2 = pd.DataFrame([[4, 5, 6]], index=["b"]) + df = DataFrame([[1, 2, 3]], index=["a"]) + df2 = DataFrame([[4, 5, 6]], index=["b"]) msg = ( "In a future version of pandas all arguments of concat" From de64cc253cf19fdfc0dd6ba85b5a26d8d71a5788 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Fri, 4 Jun 2021 13:40:17 +0100 Subject: [PATCH 12/17] Update pandas/tests/reshape/concat/test_concat.py --- pandas/tests/reshape/concat/test_concat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/reshape/concat/test_concat.py b/pandas/tests/reshape/concat/test_concat.py index 64c34240cd962..b8e93819a1d1d 100644 --- a/pandas/tests/reshape/concat/test_concat.py +++ b/pandas/tests/reshape/concat/test_concat.py @@ -650,6 +650,6 @@ def test_concat_posargs_deprecation(): "except for the argument 'objs' will be keyword-only" ) with tm.assert_produces_warning(FutureWarning, match=msg): - result = concat([df, df2], axis=0) + result = concat([df, df2], 0) expected = DataFrame([[1, 2, 3], [4, 5, 6]], index=["a", "b"]) tm.assert_frame_equal(result, expected) From cfe2f867d2ea0210db43965008ebebe179d5155b Mon Sep 17 00:00:00 2001 From: MarcoGorelli Date: Fri, 4 Jun 2021 16:26:10 +0100 Subject: [PATCH 13/17] use axis with keyword --- pandas/io/stata.py | 2 +- pandas/tests/io/pytables/test_complex.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/io/stata.py b/pandas/io/stata.py index e4f3bcb89cf7e..1fef33558dd9a 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -1762,7 +1762,7 @@ def _do_convert_missing(self, data: DataFrame, convert_missing: bool) -> DataFra columns = data.columns replacement_df = DataFrame(replacements) replaced = concat( - [data.drop(replacement_df.columns, axis=1), replacement_df], 1 + [data.drop(replacement_df.columns, axis=1), replacement_df], axis=1 ) data = replaced[columns] return data diff --git a/pandas/tests/io/pytables/test_complex.py b/pandas/tests/io/pytables/test_complex.py index 8e1dee5873512..6cfe80ae5c87c 100644 --- a/pandas/tests/io/pytables/test_complex.py +++ b/pandas/tests/io/pytables/test_complex.py @@ -205,4 +205,4 @@ def test_complex_append(setup_path): store.append("df", df, data_columns=["b"]) store.append("df", df) result = store.select("df") - tm.assert_frame_equal(pd.concat([df, df], 0), result) + tm.assert_frame_equal(pd.concat([df, df], axis=0), result) From 8d60cc288d5de5d5eac5b2529faca669a20858f3 Mon Sep 17 00:00:00 2001 From: MarcoGorelli Date: Fri, 4 Jun 2021 16:32:29 +0100 Subject: [PATCH 14/17] put deprecation decorator in function def, not overload --- pandas/core/reshape/concat.py | 2 +- pandas/tests/reshape/concat/test_concat.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/reshape/concat.py b/pandas/core/reshape/concat.py index 804418d3c4d89..ea34bc75b4e31 100644 --- a/pandas/core/reshape/concat.py +++ b/pandas/core/reshape/concat.py @@ -55,7 +55,6 @@ # Concatenate DataFrame objects -@deprecate_nonkeyword_arguments(version=None, allowed_args=["objs"]) @overload def concat( objs: Iterable[DataFrame] | Mapping[Hashable, DataFrame], @@ -88,6 +87,7 @@ def concat( ... +@deprecate_nonkeyword_arguments(version=None, allowed_args=["objs"]) def concat( objs: Iterable[NDFrame] | Mapping[Hashable, NDFrame], axis=0, diff --git a/pandas/tests/reshape/concat/test_concat.py b/pandas/tests/reshape/concat/test_concat.py index b8e93819a1d1d..17a7089f0ac85 100644 --- a/pandas/tests/reshape/concat/test_concat.py +++ b/pandas/tests/reshape/concat/test_concat.py @@ -646,7 +646,7 @@ def test_concat_posargs_deprecation(): df2 = DataFrame([[4, 5, 6]], index=["b"]) msg = ( - "In a future version of pandas all arguments of concat" + "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): From 54346cc454dec023f0f8d969303470cfac275a4f Mon Sep 17 00:00:00 2001 From: MarcoGorelli Date: Fri, 4 Jun 2021 17:29:33 +0100 Subject: [PATCH 15/17] fixup old whatsnew note --- doc/source/whatsnew/v0.17.0.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v0.17.0.rst b/doc/source/whatsnew/v0.17.0.rst index d8f39a7d6e3c0..991b9a40d151b 100644 --- a/doc/source/whatsnew/v0.17.0.rst +++ b/doc/source/whatsnew/v0.17.0.rst @@ -423,7 +423,7 @@ Other enhancements .. code-block:: ipython - In [1]: pd.concat([foo, bar, baz], 1) + In [1]: pd.concat([foo, bar, baz], axis=1) Out[1]: 0 1 2 0 1 1 4 @@ -433,7 +433,7 @@ Other enhancements .. ipython:: python - pd.concat([foo, bar, baz], 1) + pd.concat([foo, bar, baz], axis=1) - ``DataFrame`` has gained the ``nlargest`` and ``nsmallest`` methods (:issue:`10393`) From abe77dbe5c8f9f36cf8af3733b0f703840c779a6 Mon Sep 17 00:00:00 2001 From: MarcoGorelli Date: Sat, 5 Jun 2021 10:18:39 +0100 Subject: [PATCH 16/17] catch warning message --- pandas/tests/reshape/concat/test_invalid.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pandas/tests/reshape/concat/test_invalid.py b/pandas/tests/reshape/concat/test_invalid.py index 95a81ce61c785..1a26097fb406d 100644 --- a/pandas/tests/reshape/concat/test_invalid.py +++ b/pandas/tests/reshape/concat/test_invalid.py @@ -28,11 +28,16 @@ def test_concat_invalid(self): def test_concat_invalid_first_argument(self): df1 = tm.makeCustomDataframe(10, 2) df2 = tm.makeCustomDataframe(10, 2) - msg = ( + err_msg = ( "first argument must be an iterable of pandas " 'objects, you passed an object of type "DataFrame"' ) - with pytest.raises(TypeError, match=msg): + warn_msg = ( + "In a future version of pandas all arguments of concat " + "except for the argument 'objs' will be keyword-only" + ) + warning_ctx = tm.assert_produces_warning(FutureWarning, match=warn_msg) + with pytest.raises(TypeError, match=err_msg), warning_ctx: concat(df1, df2) # generator ok though From c66ebad50ebf8e29e771b32557aec71f24de05c5 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Sun, 6 Jun 2021 12:24:04 +0100 Subject: [PATCH 17/17] simplify test_invalid --- pandas/tests/reshape/concat/test_invalid.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/pandas/tests/reshape/concat/test_invalid.py b/pandas/tests/reshape/concat/test_invalid.py index 1a26097fb406d..cd2a7ca33a267 100644 --- a/pandas/tests/reshape/concat/test_invalid.py +++ b/pandas/tests/reshape/concat/test_invalid.py @@ -27,18 +27,12 @@ def test_concat_invalid(self): def test_concat_invalid_first_argument(self): df1 = tm.makeCustomDataframe(10, 2) - df2 = tm.makeCustomDataframe(10, 2) - err_msg = ( + msg = ( "first argument must be an iterable of pandas " 'objects, you passed an object of type "DataFrame"' ) - warn_msg = ( - "In a future version of pandas all arguments of concat " - "except for the argument 'objs' will be keyword-only" - ) - warning_ctx = tm.assert_produces_warning(FutureWarning, match=warn_msg) - with pytest.raises(TypeError, match=err_msg), warning_ctx: - concat(df1, df2) + with pytest.raises(TypeError, match=msg): + concat(df1) # generator ok though concat(DataFrame(np.random.rand(5, 5)) for _ in range(3))