Skip to content

Instantly share code, notes, and snippets.

@aivuk
Last active August 29, 2015 14:06
Show Gist options
  • Save aivuk/160811513acf013e14b6 to your computer and use it in GitHub Desktop.
Save aivuk/160811513acf013e14b6 to your computer and use it in GitHub Desktop.
(Pseudo) Meta Python
import pandas as pd
import numpy as np
import itertools as it
import operator as o
df = pd.DataFrame(np.random.randint(1,10,size=(100,6)), columns=['a1', 'a2', 'b1', 'b2', 'c1', 'c2'])
cs = map(lambda x: reduce(o.and_, x),
list(it.product(*[[op(df[i] == 2) for op in [lambda x: ~x, lambda x: x]] for i in ['a1', 'a2', 'c1']])))
for ci in cs:
print df[ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment