Skip to content
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

BUG: Improve error message when tansfrom() with incorrect axis #58494

Merged
merged 11 commits into from
May 10, 2024
6 changes: 5 additions & 1 deletion pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,11 @@ def normalize_dictlike_arg(

cols = Index(list(func.keys())).difference(obj.columns, sort=True)
if len(cols) > 0:
raise KeyError(f"Column(s) {list(cols)} do not exist")
raise KeyError(
f"Column(s) {list(cols)} do not exist, "
"if you don't mean to apply to each rows, "
"consider using `axis=0` instead."
)
luke396 marked this conversation as resolved.
Show resolved Hide resolved

aggregator_types = (list, tuple, dict)

Expand Down
Loading