code: def table_to_ligolw(table, tablename):
      
      from ligo.lw import lsctables
  
      # create new LIGO_LW table
      columns = table.columns.keys()
      cls = lsctables.TableByName[tablename]
      llwcolumns = list(columns)
      for col, llwcols in _get_property_columns(cls, columns).items():
          idx = llwcolumns.index(col)
          llwcolumns.pop(idx)
          for name in llwcols[::-1]:
              llwcolumns.insert(idx, name)
      llwtable = lsctables.New(cls, columns=llwcolumns)
  
      # map rows across
      for row in table:
          llwrow = llwtable.RowType()
          for name in columns:
              setattr(llwrow, name,
                      to_ligolw_table_type(row[name], llwtable, name))
          llwtable.append(llwrow)
  
      return llwtable
docs: Convert a `astropy.table.Table` to a :class:`ligo.lw.table.Table`