Skip to content

Commit 9371268

Browse files
committed
CASTable.rename implementation and tests complete
1 parent 30967c3 commit 9371268

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

swat/cas/table.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5977,27 +5977,27 @@ def rename(self, columns, errors='ignore', **kwargs):
59775977
:class:`CASTable`
59785978
'''
59795979

5980-
#Columns is a dict:
5980+
# Columns is a dict:
59815981
alterTable = []
59825982
if isinstance(columns, dict):
5983-
#Convert Pandas-style dict to CAS-style list of dicts
5983+
# Convert Pandas-style dict to CAS-style list of dicts
59845984
for oldName, newName in columns.items():
59855985
if oldName in self.columns:
59865986
alterTable.append({'name': oldName, 'rename': newName})
5987-
#If we encounter a key that doesn't exist as column
5988-
#and we are raising errors, we do that here
5987+
# If we encounter a key that doesn't exist as column
5988+
# and we are raising errors, we do that here
59895989
elif errors == 'raise':
59905990
raise KeyError("Column is not found in CASTable: " + oldName)
59915991

5992-
#Columns is a function:
5992+
# Columns is a function:
59935993
elif callable(columns):
5994-
#Iterate through all table columns and apply function
5994+
# Iterate through all table columns and apply function
59955995
for col in self.columns:
59965996
alterTable.append({'name': col, 'rename': columns(col)})
59975997
else:
59985998
raise TypeError("Columns must be a dict or function")
59995999

6000-
#Use list of dicts to rename using alterTable action
6000+
# Use list of dicts to rename using alterTable action
60016001
self._retrieve('alterTable', columns=alterTable)
60026002
return self
60036003

0 commit comments

Comments
 (0)