Paste P6454

(An Untitled Masterwork)
ActivePublic

Authored by EBernhardson on Dec 12 2017, 11:53 PM.
def stripUnderscores(structType, prefix=''):
output = []
for name, field in zip(structType.names, structType.fields):
if isinstance(field.dataType, T.StructType):
col = F.struct(*stripUnderscores(field.dataType, prefix + name + '.'))
else:
col = F.col(prefix + name)
output.append(col.alias(name.replace(' ', '_')))
return output