Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. allrows = [['NEPW46486', 'NEPW46550', 'sersic', 20.04, 21.12],
  2. ['NEPW89344', 'NEPW89346', 'sersic', 20.33, 19.66], ...]
  3.  
  4. cols = [['NEPW46486', 'NEPW89344', ...], ['NEPW46550', 'NEPW89346', ...], ['sersic', 'sersic', ...], [20.04, 20.33, ...], [21.12, 19.66, ...]]
  5.  
  6. cols = [[row[n] for row in allrows] for n in range(len(row))]
  7.  
  8. allrows = [['NEPW46486', 'NEPW46550', 'sersic', 20.04, 21.12],
  9. ['NEPW89344', 'NEPW89346', 'sersic', 20.33, 19.66]]
  10.  
  11. for item in zip(*allrows): # unpack with *allrows
  12. print(item)
  13.  
  14. ('NEPW46486', 'NEPW89344')
  15. ('NEPW46550', 'NEPW89346')
  16. ('sersic', 'sersic')
  17. (20.04, 20.33)
  18. (21.12, 19.66)
  19.  
  20. cols = []
  21. for index, item in enumerate(allrows[0]):
  22. col = []
  23. for row in allrows:
  24. col.append(row[index])
  25. cols.append(col)
  26. print(cols)
  27.  
  28. cols = [[row[index] for row in allrows] for index, item in enumerate(allrows[0])]
  29. print(cols)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement