Skip to content
  • View menu
  • View sidebar

bioinfo core

Index & solution of bioInfo utilities

  • Home
  • All entries
  • Blogs
  • Contact
  • About

Categories

  • Between languages (7)
  • Blogs (8)
  • Python (35)
  • R (1)
  • Unix (37)

Tags

bedfile Blogs conda Excel html numpy Pandas Python R slurm Unix
06/27/202201/19/2023 by bioinfocore

python select items from a list using a boolean array

  • Python
  • numpy, Python
from itertools import compress

arr = np.array([x=='TRUE' for x in xList]) # Turn a string list to boolean
list(compress(yList, arr))

Source:
https://www.geeksforgeeks.org/python-itertools-compress/

Post navigation

← Previous Post Slurm sbatch specify nodes or node list
Next Post → Rasterize points in scatterplot
Copyright 2022 | by bioinfocore