Paste P6454

(An Untitled Masterwork)
ActivePublic

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