Skip to content

Instantly share code, notes, and snippets.

@n9986
Created September 22, 2012 05:44
Show Gist options
  • Save n9986/3765268 to your computer and use it in GitHub Desktop.
Save n9986/3765268 to your computer and use it in GitHub Desktop.
Item in tuple finder using numpy
# Works for nicely ordered data
import numpy as np
RECIPES = (
('apple', 'sugar', 'extreme_Force'),
('banana', 'syrup', 'magical_ends'),
('caramel', 'chocolate', 'pancake_MONSTER'),
)
np_recipes = np.array(recipes)
indices = zip(*np.where( np_recipes == 'banana' ) ) #[(1, 0)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment