Skip to content

Commit 990240e

Browse files
committed
Use "msg" not "err"
1 parent fd3ebf6 commit 990240e

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pandas/core/arrays/categorical.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -633,18 +633,16 @@ def from_codes(cls, codes, categories, ordered=False):
633633
"""
634634
codes = np.asarray(codes)
635635
if not is_integer_dtype(codes):
636-
err = True
636+
msg = "codes need to be array-like integers"
637637
if is_float_dtype(codes):
638638
icodes = codes.astype('i8')
639639
if (icodes == codes).all():
640-
err = False
640+
msg = None
641641
codes = icodes
642-
warn("float codes will be disallowed in the future",
643-
FutureWarning, stacklevel=2)
644-
else:
645-
err = True
646-
if err:
647-
raise ValueError("codes need to be array-like integers")
642+
warn(("float codes will be disallowed in the future and "
643+
"raise a ValueError"), FutureWarning, stacklevel=2)
644+
if msg:
645+
raise ValueError(msg)
648646

649647
try:
650648
codes = coerce_indexer_dtype(codes, categories)

0 commit comments

Comments
 (0)