From 6a67b56cb42ba50351517b891ece37d96bc0b503 Mon Sep 17 00:00:00 2001 From: Jonas Haag Date: Tue, 10 Jan 2023 11:26:04 +0100 Subject: [PATCH 1/5] Update construction.py --- pandas/core/construction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/construction.py b/pandas/core/construction.py index 5a80fdb6d9e0e..52a1da31873b4 100644 --- a/pandas/core/construction.py +++ b/pandas/core/construction.py @@ -666,7 +666,7 @@ def _sanitize_ndim( if isinstance(data, np.ndarray): if allow_2d: return result - raise ValueError("Data must be 1-dimensional") + raise ValueError(f"Data must be 1-dimensional, got ndarray of shape {data.shape} instead") if is_object_dtype(dtype) and isinstance(dtype, ExtensionDtype): # i.e. PandasDtype("O") From 5c78ff624a73c0e4905e2de3747bc03373fdf8af Mon Sep 17 00:00:00 2001 From: Jonas Haag Date: Tue, 10 Jan 2023 11:27:01 +0100 Subject: [PATCH 2/5] Update test_constructors.py --- pandas/tests/series/test_constructors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index f856f18552594..7581dbc3aaa06 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -172,7 +172,7 @@ def test_constructor(self, datetime_series): assert not Series().index._is_all_dates # exception raised is of type ValueError GH35744 - with pytest.raises(ValueError, match="Data must be 1-dimensional"): + with pytest.raises(ValueError, match="Data must be 1-dimensional, got ndarray of shape \(3, 3\) instead""): Series(np.random.randn(3, 3), index=np.arange(3)) mixed.name = "Series" From 02b575163d8bbbeb91572637f29fdcf60ec8c323 Mon Sep 17 00:00:00 2001 From: Jonas Haag Date: Tue, 10 Jan 2023 11:58:12 +0100 Subject: [PATCH 3/5] Update test_constructors.py --- pandas/tests/series/test_constructors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index 7581dbc3aaa06..6105397ec28cc 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -172,7 +172,7 @@ def test_constructor(self, datetime_series): assert not Series().index._is_all_dates # exception raised is of type ValueError GH35744 - with pytest.raises(ValueError, match="Data must be 1-dimensional, got ndarray of shape \(3, 3\) instead""): + with pytest.raises(ValueError, match=r"Data must be 1-dimensional, got ndarray of shape \(3, 3\) instead"): Series(np.random.randn(3, 3), index=np.arange(3)) mixed.name = "Series" From 9d4691558b43e932f65f2b760eafc91245435d27 Mon Sep 17 00:00:00 2001 From: Jonas Haag Date: Tue, 10 Jan 2023 13:45:14 +0100 Subject: [PATCH 4/5] Update construction.py --- pandas/core/construction.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/construction.py b/pandas/core/construction.py index 52a1da31873b4..5593826218fec 100644 --- a/pandas/core/construction.py +++ b/pandas/core/construction.py @@ -666,7 +666,9 @@ def _sanitize_ndim( if isinstance(data, np.ndarray): if allow_2d: return result - raise ValueError(f"Data must be 1-dimensional, got ndarray of shape {data.shape} instead") + raise ValueError( + f"Data must be 1-dimensional, got ndarray of shape {data.shape} instead" + ) if is_object_dtype(dtype) and isinstance(dtype, ExtensionDtype): # i.e. PandasDtype("O") From f5b88d32258cc30ac900fff9afad96992d298ed5 Mon Sep 17 00:00:00 2001 From: Jonas Haag Date: Tue, 10 Jan 2023 13:45:37 +0100 Subject: [PATCH 5/5] Update test_constructors.py --- pandas/tests/series/test_constructors.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index 6105397ec28cc..7b4b1b505a0bd 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -172,7 +172,10 @@ def test_constructor(self, datetime_series): assert not Series().index._is_all_dates # exception raised is of type ValueError GH35744 - with pytest.raises(ValueError, match=r"Data must be 1-dimensional, got ndarray of shape \(3, 3\) instead"): + with pytest.raises( + ValueError, + match=r"Data must be 1-dimensional, got ndarray of shape \(3, 3\) instead", + ): Series(np.random.randn(3, 3), index=np.arange(3)) mixed.name = "Series"