adding the strict flag

This commit is contained in:
Steve Nyemba 2019-03-08 18:02:06 -06:00
parent e33223f6b2
commit 084e7d0fe8
1 changed files with 5 additions and 3 deletions

View File

@ -76,7 +76,7 @@ class deid :
sample = args['sample'] if 'sample' in args else pd.DataFrame(self._df) sample = args['sample'] if 'sample' in args else pd.DataFrame(self._df)
k = sample.columns.size if 'field_count' not in args else int(args['field_count']) + 1 k = sample.columns.size if 'field_count' not in args else int(args['field_count']) +1
if 'id' in args : if 'id' in args :
id = args['id'] id = args['id']
columns = list(set(sample.columns.tolist()) - set([id])) columns = list(set(sample.columns.tolist()) - set([id]))
@ -85,8 +85,10 @@ class deid :
o = pd.DataFrame() o = pd.DataFrame()
for i in np.arange(RUNS): for i in np.arange(RUNS):
if 'strict' not in args :
n = np.random.randint(2,k) n = np.random.randint(2,k)
else:
n = args['field_count']
cols = np.random.choice(columns,n,replace=False).tolist() cols = np.random.choice(columns,n,replace=False).tolist()
params = {'sample':sample,'cols':cols} params = {'sample':sample,'cols':cols}
if pop is not None : if pop is not None :