From d78bd7a65f87022bae5021d36c8656c0ea5a7b76 Mon Sep 17 00:00:00 2001 From: topper-123 Date: Sat, 3 Nov 2018 14:40:08 +0000 Subject: [PATCH] CLN: doc string (#23469) --- pandas/core/generic.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 6ca8f6731bbb8..d1e9f103477cc 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -5279,7 +5279,9 @@ def astype(self, dtype, copy=True, errors='raise', **kwargs): Convert to ordered categorical type with custom ordering: - >>> ser.astype('category', ordered=True, categories=[2, 1]) + >>> cat_dtype = pd.api.types.CategoricalDtype( + ... categories=[2, 1], ordered=True) + >>> ser.astype(cat_dtype) 0 1 1 2 dtype: category