if depth == 0:
    return pd.Series(dic)
elif depth > 0:
    keys = []
vals = []
for k, v in list(dic.items()):
    keys.append(k)
vals.append(frame_from_dict(v, depth - 1))
try:
    keys = sorted(keys)
except TypeError:
    pass
return pd.concat(vals, axis=1, keys=keys, **kwargs)
raise ValueError('depth should be a nonnegative integer or None')
Nested dictionary of namedtuples to pandas dataframe