Skip to content

Commit 426dfc6

Browse files
author
PaulWestenthanner
committed
fix #441: Use future behaviour of fillna without downcast
1 parent 9dbbd90 commit 426dfc6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

category_encoders/ordinal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ def ordinal_encoding(X_in, mapping=None, cols=None, handle_unknown='value', hand
195195

196196
# Convert to object to accept np.nan (dtype string doesn't)
197197
# fillna changes None and pd.NA to np.nan
198-
X[column] = X[column].astype("object").fillna(np.nan).map(col_mapping)
198+
with pd.option_context('future.no_silent_downcasting', True):
199+
X[column] = X[column].astype("object").fillna(np.nan).map(col_mapping)
199200
if util.is_category(X[column].dtype):
200201
nan_identity = col_mapping.loc[col_mapping.index.isna()].array[0]
201202
X[column] = X[column].cat.add_categories(nan_identity)

0 commit comments

Comments
 (0)