Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- allrows = [['NEPW46486', 'NEPW46550', 'sersic', 20.04, 21.12],
- ['NEPW89344', 'NEPW89346', 'sersic', 20.33, 19.66], ...]
- cols = [['NEPW46486', 'NEPW89344', ...], ['NEPW46550', 'NEPW89346', ...], ['sersic', 'sersic', ...], [20.04, 20.33, ...], [21.12, 19.66, ...]]
- cols = [[row[n] for row in allrows] for n in range(len(row))]
- allrows = [['NEPW46486', 'NEPW46550', 'sersic', 20.04, 21.12],
- ['NEPW89344', 'NEPW89346', 'sersic', 20.33, 19.66]]
- for item in zip(*allrows): # unpack with *allrows
- print(item)
- ('NEPW46486', 'NEPW89344')
- ('NEPW46550', 'NEPW89346')
- ('sersic', 'sersic')
- (20.04, 20.33)
- (21.12, 19.66)
- cols = []
- for index, item in enumerate(allrows[0]):
- col = []
- for row in allrows:
- col.append(row[index])
- cols.append(col)
- print(cols)
- cols = [[row[index] for row in allrows] for index, item in enumerate(allrows[0])]
- print(cols)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement