Skip to content

Commit 0205340

Browse files
Adjusted method ordinal_encoding when it get's a dataframe with dtype='string' (#277)
The problem occurs because the dataframe contains `dtype='string'` parameter. With this, the `unique()` method returns `StringArray` object, no np array. Instead of using `tolist` method, it was included the `list` call outside. Co-authored-by: Leonardo <leonardo.fiedler@senior.com.br>
1 parent d8df67c commit 0205340

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

category_encoders/ordinal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ def ordinal_encoding(X_in, mapping=None, cols=None, handle_unknown='value', hand
319319
for col in cols:
320320

321321
nan_identity = np.nan
322-
323-
categories = X[col].unique().tolist()
322+
323+
categories = list(X[col].unique())
324324
if util.is_category(X[col].dtype):
325325
# Avoid using pandas category dtype meta-data if possible, see #235, #238.
326326
if X[col].dtype.ordered:

0 commit comments

Comments
 (0)