Skip to content

Instantly share code, notes, and snippets.

@ilkayisik
Created February 3, 2020 16:36
Show Gist options
  • Save ilkayisik/e84394d3c8639fa01bba40780c36ff55 to your computer and use it in GitHub Desktop.
Save ilkayisik/e84394d3c8639fa01bba40780c36ff55 to your computer and use it in GitHub Desktop.
remove list element that starts with a certain expression
labels = ['pericalc','FFA','MT','comb_a','comb_b']
comb_ind = [labels.index(l) for l in labels if l.startswith('comb')]
len_comb = len(comb_ind)
arr = np.arange(len(labels))
arr = list(arr[~np.isin(arr, comb_ind)])
labels = [i for j, i in enumerate(labels) if j in arr]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment