From 5692a40c73d23c1b60bb9ab338353c3b12dcddb7 Mon Sep 17 00:00:00 2001 From: Ahmad Mustafa Anis Date: Mon, 30 Oct 2023 14:58:22 +0500 Subject: [PATCH 1/3] Update _core.py to show valid plot types in the Error Message for Invalid Plots If an invalid plot type is passed, the error message raised is ``` raise ValueError(f"{kind} is not a valid plot kind") ``` To give more context to user, it should also show the valid plot kinds. --- pandas/plotting/_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 0eb8ab2412e0e..58fb333a5042c 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -961,7 +961,7 @@ def __call__(self, *args, **kwargs): return plot_backend.plot(self._parent, x=x, y=y, kind=kind, **kwargs) if kind not in self._all_kinds: - raise ValueError(f"{kind} is not a valid plot kind") + raise ValueError(f"{kind} is not a valid plot kind\nValid plot kinds {self._all_kinds}") # The original data structured can be transformed before passed to the # backend. For example, for DataFrame is common to set the index as the From 5b228113bba849fe8313a57578b944442e8fb2fb Mon Sep 17 00:00:00 2001 From: Ahmad Mustafa Anis Date: Mon, 30 Oct 2023 23:01:18 +0500 Subject: [PATCH 2/3] Update _core.py with multiline exception message --- pandas/plotting/_core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 58fb333a5042c..74e680c307c62 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -961,7 +961,10 @@ def __call__(self, *args, **kwargs): return plot_backend.plot(self._parent, x=x, y=y, kind=kind, **kwargs) if kind not in self._all_kinds: - raise ValueError(f"{kind} is not a valid plot kind\nValid plot kinds {self._all_kinds}") + raise ValueError( + f"{kind} is not a valid plot kind " + f"Valid plot kinds: {self._all_kinds}" + ) # The original data structured can be transformed before passed to the # backend. For example, for DataFrame is common to set the index as the From 9f1683a66b8736540cc389e2e719417bd993a0e0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 31 Oct 2023 16:43:27 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pandas/plotting/_core.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 74e680c307c62..3b60e95b9dceb 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -962,9 +962,9 @@ def __call__(self, *args, **kwargs): if kind not in self._all_kinds: raise ValueError( - f"{kind} is not a valid plot kind " - f"Valid plot kinds: {self._all_kinds}" - ) + f"{kind} is not a valid plot kind " + f"Valid plot kinds: {self._all_kinds}" + ) # The original data structured can be transformed before passed to the # backend. For example, for DataFrame is common to set the index as the