Skip to content

Commit 0185ffa

Browse files
author
Kristjan
committed
Made function faster and more secure by removing query command
def set_VALUE_at_KEY_and_ID(data, key, value, id): """Set all values of provided key and id to the given value"""
1 parent b8c3ea6 commit 0185ffa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

triplets/rdf_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def set_VALUE_at_KEY(data, key, value):
546546

547547
def set_VALUE_at_KEY_and_ID(data, key, value, id):
548548
"""Set all values of provided key and id to the given value"""
549-
data.loc[data.query(f"ID == '{id}' and KEY == '{key}'").index, "VALUE"] = value
549+
data.loc[data[(data.ID == id) & (data.KEY == key)].index, "VALUE"] = value
550550

551551
# Extend this functionality to pandas DataFrame
552552
pandas.DataFrame.set_VALUE_at_KEY_and_ID = set_VALUE_at_KEY_and_ID

0 commit comments

Comments
 (0)