Here is a version that uses only the built-in list methods.
This is rather naive, therefore there may be solutions that are faster, but do not need additional packages, etc., that you may need.
def remove_abnormalities(values, indices): list = [] for i in range(len(values)): if i not in indices: list.append(values[i]) return list print(remove_abnormalities(["A","B","C","D","E","F","G","H"],[1,3,5]))
If there are other Python gurus who would like to suggest changes / optimizations with this, no problem.
EDIT
I tried to use the timeit functions timeit both fantasy and my naive implementations, they are not final, but they do not seem faster than others. However, this is done manually in the interpreter. Failed to get the script working. In terms of performance, they are not much different. I would not mind if someone else can prove to me that it is wrong!
source share