@@ -5959,7 +5959,7 @@ def drop_duplicates(self, casout, subset=[]):
5959
5959
# def reindex_like(self, *args, **kwargs):
5960
5960
# raise NotImplementedError
5961
5961
5962
- def rename (self , columns , errors = 'ignore' , inplace = True , ** kwargs ):
5962
+ def rename (self , columns , errors = 'ignore' , ** kwargs ):
5963
5963
'''
5964
5964
Rename columns of the CASTable.
5965
5965
@@ -5976,18 +5976,12 @@ def rename(self, columns, errors='ignore', inplace=True, **kwargs):
5976
5976
-------
5977
5977
:class:`CASTable`
5978
5978
'''
5979
- #If we are working in place, our working table is the table itself
5980
- table = self
5981
- #If not, we need to make a copy
5982
- if not inplace :
5983
- table = copy .deepcopy (self )
5984
-
5985
5979
#Columns is a dict:
5986
5980
alterTable = []
5987
5981
if isinstance (columns , dict ):
5988
5982
#Convert Pandas-style dict to CAS-style list of dicts
5989
5983
for oldName , newName in columns .items ():
5990
- if oldName in table .columns :
5984
+ if oldName in self .columns :
5991
5985
alterTable .append ({'name' : oldName , 'rename' : newName })
5992
5986
#If we encounter a key that doesn't exist as column
5993
5987
#and we are raising errors, we do that here
@@ -5997,14 +5991,14 @@ def rename(self, columns, errors='ignore', inplace=True, **kwargs):
5997
5991
#Columns is a function:
5998
5992
elif callable (columns ):
5999
5993
#Iterate through all table columns and apply function
6000
- for col in table .columns :
5994
+ for col in self .columns :
6001
5995
alterTable .append ({'name' : col , 'rename' : columns (col )})
6002
5996
else :
6003
5997
raise TypeError ("Columns must be a dict or function" )
6004
5998
6005
5999
#Use list of dicts to rename using alterTable action
6006
- table ._retrieve ('alterTable' , columns = alterTable )
6007
- return table
6000
+ self ._retrieve ('alterTable' , columns = alterTable )
6001
+ return self
6008
6002
6009
6003
def reset_index (self , level = None , drop = False , inplace = False ,
6010
6004
col_level = 0 , col_fill = '' , ** kwargs ):
0 commit comments