python matrix transpose and zip

后端 未结 6 1130
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 11:32

How to get the transpose of this matrix..Any easier ,algorithmic way to do this...

1st question:

 Input  a=[[1,2,3],[4,5,6],[7,8,9]]
 Expected outpu         


        
6条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-30 11:57

    Try this replacing appropriate variable

    import numpy as np
    
    data = ((0, 1, 2), (3, 4, 5), (6, 7, 8), (9, 10, 11))
    
    data_transpose = np.transpose(data) # replace with your code
    print(data_transpose)
    

提交回复
热议问题