Retrieve keys of a dict

    :param expr: dict sequence / scalar
    :return:
486437
def _keys(expr):
    
    if isinstance(expr, SequenceExpr):
        dtype = expr.data_type
    else:
        dtype = expr.value_type
    return composite_op(expr, DictKeys, df_types.List(dtype.key_type))
715140
def _extract_format_keys(self, fmt_string):
        

        class AccessSaver:
            def __init__(self):
                self.keys = []

            def __getitem__(self, key):
                self.keys.append(key)

        a = AccessSaver()
        fmt_string % a

        return a.keys
181902
def tolist(expr, **kwargs):
    
    unique = kwargs.get('unique', kwargs.get('_unique', False))
    output_type = None

    if isinstance(expr, (SequenceExpr, SequenceGroupBy)):
        output_type = types.List(expr._data_type)
    return _reduction(expr, ToList, output_type, _unique=unique)
406044
def convert(self, expr):
        
        if type(expr) is BV:
            if expr.op == "BVV":
                cached_obj = self._object_cache.get(expr._cache_key, None)
                if cached_obj is None:
                    cached_obj = self.BVV(*expr.args)
                    self._object_cache[expr._cache_key] = cached_obj
                return cached_obj
        if type(expr) is Bool and expr.op == "BoolV":
            return expr.args[0]
        return super().convert(expr)
616362
def collection_keys(coll, sep='.'):
    
    def _keys(x, pre=''):
        for k in x:
            yield (pre + k)
            if isinstance(x[k], dict):
                for nested in _keys(x[k], pre + k + sep):
                    yield nested

    return list(_keys(coll.find_one()))
1094090
def INIT_LIST_EXPR(self, cursor):
        """"""
        values = [self.parse_cursor(child)
                  for child in list(cursor.get_children())]
        return values
1043199
def rex(expr):
    
    r = re.compile(expr)
    return lambda key: isinstance(key, six.string_types) and r.match(key)
1034901
def expr_to_json(expr):
    
    if isinstance(expr, symbolics.Mul):
        return {"type": "Mul", "args": [expr_to_json(arg) for arg in expr.args]}
    elif isinstance(expr, symbolics.Add):
        return {"type": "Add", "args": [expr_to_json(arg) for arg in expr.args]}
    elif isinstance(expr, symbolics.Symbol):
        return {"type": "Symbol", "name": expr.name}
    elif isinstance(expr, symbolics.Pow):
        return {"type": "Pow", "args": [expr_to_json(arg) for arg in expr.args]}
    elif isinstance(expr, (float, int)):
        return {"type": "Number", "value": expr}
    elif isinstance(expr, symbolics.Real):
        return {"type": "Number", "value": float(expr)}
    elif isinstance(expr, symbolics.Integer):
        return {"type": "Number", "value": int(expr)}
    else:
        raise NotImplementedError("Type not implemented: " + str(type(expr)))
197251
def _rel(self, copy=False):
        
        rel = {}
        for key, obj in vars(self).items():
            if not isinstance(obj, (pd.Series, pd.DataFrame, pd.SparseSeries, pd.SparseDataFrame)) and not key.startswith('_'):
                if copy and 'id' not in key:
                    rel[key] = deepcopy(obj)
                else:
                    rel[key] = obj
        return rel
248179
def get_keys_from_value(self, value):
        

        return [key for key, data in self.iteritems() if data == value]
167298
def __convert_key(expression):
        
        if type(expression) is str and len(expression) > 2 and expression[1] == '!':
            expression = eval(expression[2:-1])
        return expression
1163677
def get_inner_keys(dictionary):
    

    keys = []

    for key in dictionary.keys():
        inner_keys = dictionary[key].keys()
        keys += [
            key + " " + inner_key  # concatenate
            for inner_key in inner_keys
        ]

    return keys
1130847
def fetch(self, keyDict):
        
        for key in keyDict:
            keyDict[key] = self.dict[key]
1042250
def dict(self, var, default=NOTSET, cast=None, force=True):
        
        return self._get(var, default=default, cast={str: cast}, force=force)
1366462
def group_by_key_impl(sequence):
    
    result = {}
    for element in sequence:
        if result.get(element[0]):
            result.get(element[0]).append(element[1])
        else:
            result[element[0]] = [element[1]]
    return six.viewitems(result)
866535
def keys(self, index=None):
        
        with self._lmdb.begin() as txn:
            return [key.decode() for key, _ in txn.cursor()]
1097761
def get_indices(s: Union[str, 'ChainedBase']) -> Dict[int, str]:
    
    codes = get_code_indices(s)
    if not codes:
        # This function is not for non-escape-code stuff, but okay.
        return {i: c for i, c in enumerate(s)}

    indices = {}
    for codeindex in sorted(codes):
        code = codes[codeindex]
        if codeindex == 0:
            indices[codeindex] = code
            continue
        # Grab characters before codeindex.
        start = max(indices or {0: ''}, key=int)
        startcode = indices.get(start, '')
        startlen = start + len(startcode)
        indices.update({i: s[i] for i in range(startlen, codeindex)})
        indices[codeindex] = code

    if not indices:
        return {i: c for i, c in enumerate(s)}
    lastindex = max(indices, key=int)
    lastitem = indices[lastindex]
    start = lastindex + len(lastitem)
    textlen = len(s)
    if start < (textlen - 1):
        # Grab chars after last code.
        indices.update({i: s[i] for i in range(start, textlen)})
    return indices