@@ -188,20 +188,20 @@ def inverse_transform(self, X_in):
188188 raise ValueError (f'Unexpected input dimension { X .shape [1 ]} , expected { self ._dim } ' )
189189
190190 if not list (self .cols ):
191- return X if self .return_df else X .values
191+ return X if self .return_df else X .to_numpy ()
192192
193193 for switch in self .ordinal_encoder .mapping :
194194 column_mapping = switch .get ('mapping' )
195- inverse = pd .Series (data = column_mapping .index , index = column_mapping .values )
195+ inverse = pd .Series (data = column_mapping .index , index = column_mapping .array )
196196 X [switch .get ('col' )] = X [switch .get ('col' )].map (inverse ).astype (switch .get ('data_type' ))
197197
198198 if self .handle_unknown == 'return_nan' and self .handle_missing == 'return_nan' :
199199 for col in self .cols :
200- if X [switch .get ('col' )].isnull ().any ():
200+ if X [switch .get ('col' )].isna ().any ():
201201 warnings .warn ("inverse_transform is not supported because transform impute "
202202 f"the unknown category nan when encode { col } " )
203203
204- return X if self .return_df else X .values
204+ return X if self .return_df else X .to_numpy ()
205205
206206 def calc_required_digits (self , values ):
207207 # figure out how many digits we need to represent the classes present
@@ -212,7 +212,7 @@ def calc_required_digits(self, values):
212212
213213 return digits
214214
215- def basen_encode (self , X_in , cols = None ):
215+ def basen_encode (self , X_in : pd . DataFrame , cols = None ):
216216 """
217217 Basen encoding encodes the integers as basen code with one column per digit.
218218
@@ -230,22 +230,22 @@ def basen_encode(self, X_in, cols=None):
230230
231231 X = X_in .copy (deep = True )
232232
233- cols = X .columns .values . tolist ()
233+ cols = X .columns .tolist ()
234234
235235 for switch in self .mapping :
236236 col = switch .get ('col' )
237237 mod = switch .get ('mapping' )
238238
239239 base_df = mod .reindex (X [col ])
240- base_df .set_index (X .index , inplace = True )
240+ base_df = base_df .set_index (X .index )
241241 X = pd .concat ([base_df , X ], axis = 1 )
242242
243243 old_column_index = cols .index (col )
244244 cols [old_column_index : old_column_index + 1 ] = mod .columns
245245
246246 return X .reindex (columns = cols )
247247
248- def basen_to_integer (self , X , cols , base ):
248+ def basen_to_integer (self , X : pd . DataFrame , cols , base ):
249249 """
250250 Convert basen code as integers.
251251
@@ -263,7 +263,7 @@ def basen_to_integer(self, X, cols, base):
263263 numerical: DataFrame
264264
265265 """
266- out_cols = X .columns .values . tolist ()
266+ out_cols = X .columns .tolist ()
267267
268268 for col in cols :
269269 col_list = [col0 for col0 in out_cols if re .match (re .escape (str (col ))+ '_\\ d+' , str (col0 ))]
@@ -275,8 +275,8 @@ def basen_to_integer(self, X, cols, base):
275275 len0 = len (col_list )
276276 value_array = np .array ([base ** (len0 - 1 - i ) for i in range (len0 )])
277277 X .insert (insert_at , col , np .dot (X [col_list ].values , value_array .T ))
278- X .drop (col_list , axis = 1 , inplace = True )
279- out_cols = X .columns .values . tolist ()
278+ X = X .drop (col_list , axis = 1 )
279+ out_cols = X .columns .tolist ()
280280
281281 return X
282282
0 commit comments