Skip to content

Commit

Permalink
Update _core.py to show valid plot types in the Error Message for Inv…
Browse files Browse the repository at this point in the history
…alid plot kind (#55758)

* 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.

* Update _core.py with multiline exception message

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ahmadmustafaanis and pre-commit-ci[bot] authored Oct 31, 2023
1 parent b0a0c68 commit ecf449b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
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
Expand Down

1 comment on commit ecf449b

@ahmadbinshafiq
Copy link

Choose a reason for hiding this comment

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

What a helpful feature! Really interesting and it will really help the development process.

Please sign in to comment.