def nested_to_record(ds, prefix='', level=0):
 singleton = False
 if isinstance(ds, dict):
  ds = [ds]
  singleton = True
 new_ds = []
 for d in ds:
  new_d = copy.deepcopy(d)
  for (k, v) in d.items():
   if (not isinstance(k, compat.string_types)):
    k = str(k)
   if (level == 0):
    newkey = k
   else:
    newkey = ((prefix + '.') + k)
   if (not isinstance(v, dict)):
    if (level != 0):
     v = new_d.pop(k)
     new_d[newkey] = v
    continue
   else:
    v = new_d.pop(k)
    new_d.update(nested_to_record(v, newkey, (level + 1)))
  new_ds.append(new_d)
 if singleton:
  return new_ds[0]
 return new_ds

def nested_to_record ( ds , prefix = '' , level = 0 ) : singleton = False if isinstance ( ds , dict ) : ds = [ ds ] singleton = True new_ds = [ ] for d in ds : new_d = copy . deepcopy ( d ) for ( k , v ) in d . items ( ) : if ( not isinstance ( k , compat . string_types ) ) : k = str ( k ) if ( level == 0 ) : newkey = k else : newkey = ( ( prefix + '.' ) + k ) if ( not isinstance ( v , dict ) ) : if ( level != 0 ) : v = new_d . pop ( k ) new_d [ newkey ] = v continue else : v = new_d . pop ( k ) new_d . update ( nested_to_record ( v , newkey , ( level + 1 ) ) ) new_ds . append ( new_d ) if singleton : return new_ds [ 0 ] return new_ds
a simplified json_normalize converts a nested dict into a flat dict .