Last active
August 29, 2015 14:06
-
-
Save aivuk/160811513acf013e14b6 to your computer and use it in GitHub Desktop.
(Pseudo) Meta Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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