Skip to content

Commit 9107624

Browse files
committed
improve error verbosity
1 parent 912293a commit 9107624

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pandas/core/strings/accessor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ def _validate(data):
255255
inferred_dtype = lib.infer_dtype(values, skipna=True)
256256

257257
if inferred_dtype not in allowed_types:
258-
raise AttributeError("Can only use .str accessor with string values!")
258+
raise AttributeError(
259+
f"Can only use .str accessor with string values!, not {inferred_dtype}"
260+
)
259261
return inferred_dtype
260262

261263
def __getitem__(self, key):

0 commit comments

Comments
 (0)