Created
September 3, 2014 20:21
-
-
Save aivuk/04e72ce55d4133822b71 to your computer and use it in GitHub Desktop.
Better (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']) | |
q = map(lambda x: '&'.join(x), it.product(*[['{}({} == 2)'.format(op, i) for op in ['~', '']] for i in ['a1', 'a2']])) | |
for qi in q: | |
print qi | |
print df.query(qi) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment