Skip to content

Instantly share code, notes, and snippets.

@cosmic-cortex
Last active May 5, 2020 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosmic-cortex/520d29c26a01a9a47a1c115f545049a6 to your computer and use it in GitHub Desktop.
Save cosmic-cortex/520d29c26a01a9a47a1c115f545049a6 to your computer and use it in GitHub Desktop.
def _columns_in_table(table: Set[Record]) -> set:
return set.union(*[set(record.keys()) for record in table])
def rename(table: Set[Record], columns: dict) -> Set[Record]:
table_columns = _columns_in_table(table)
table_out = {
Record({columns.get(old_name, old_name): record[old_name] for old_name in table_columns})
for record in table
}
return table_out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment