Skip to content

Instantly share code, notes, and snippets.

@zimmerrol
Created January 23, 2018 14:13
Show Gist options
  • Save zimmerrol/9540c60b0bf4ac9abef472bf44bdb48d to your computer and use it in GitHub Desktop.
Save zimmerrol/9540c60b0bf4ac9abef472bf44bdb48d to your computer and use it in GitHub Desktop.
lautze.py
lst = [(123, 456, 789), (123, 465, 789), (125, 456, 734)]
import numpy as np
#get unique IDs
fstuniq = np.unique([x[0] for x in lst])
snduniq = np.unique([x[1] for x in lst])
trduniq = np.unique([x[2] for x in lst])
print(fstuniq)
print(snduniq)
print(trduniq)
#get unique second IDs where first ID equals value
value = 123
specfstsnduniq = np.unique([x[1] for x in lst if x[0] == value])
print(specfstsnduniq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment