Skip to content

Commit 7279258

Browse files
author
Michael Erickson
committed
Updated errors='raise' check
1 parent 98dbbbe commit 7279258

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
@@ -5980,15 +5980,15 @@ def rename(self, columns, errors='ignore', inplace=True, **kwargs):
59805980
#Columns is a dict:
59815981
alterTable = []
59825982
if isinstance(columns, dict):
5983-
#Errors to be raised -> check all keys upfront
5984-
if errors == 'raise':
5985-
for key in columns.keys():
5986-
if key not in self.columns:
5987-
raise KeyError("Column is not found in CASTable: " + key)
5988-
59895983
#Convert Pandas-style dict to CAS-style list of dicts
59905984
for oldName, newName in columns.items():
5991-
alterTable.append({'name': oldName, 'rename': newName})
5985+
if oldName in self.columns:
5986+
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
5989+
elif errors == 'raise':
5990+
raise KeyError("Column is not found in CASTable: " + oldName)
5991+
59925992
#Columns is a function:
59935993
elif callable(columns):
59945994
#Iterate through all table columns and apply function

0 commit comments

Comments
 (0)