def test_dump_all(self): from ambry import get_library from censuslib.dimensions import classify l = get_library() p = l.partition('census.gov-acs-p5ye2014-b01001') for c in p.table.columns: if c.name == 'id': continue if not c.name.endswith('_m90'): print c.name, classify(c)
def dim_columns(self, pred): """ Return a list of columns that have a particular value for age, sex and race_eth. The `pred` parameter is a string of python code which is evaled, with the classification dict as the local variable context, so the code string can access these variables: - sex - age - race-eth - col_num Col_num is the number in the last three digits of the column name Some examples of predicate strings: - "sex == 'male' and age != 'na' " :param pred: A string of python code that is executed to find column matches. """ from censuslib.dimensions import classify out_cols = [] for i, c in enumerate(self.partition.table.columns): if c.name.endswith('_m90'): continue if i < 9: continue cf = classify(c) cf['col_num'] = int(c.name[-3:]) if eval(pred, {}, cf): out_cols.append(c.name) return out_cols