python, numpy; How to insert element at the start of an array

前端 未结 5 1701
梦毁少年i
梦毁少年i 2021-02-12 11:27

I have an numpy array of complex numbers. So I want to insert zero at start of the array, and shift the rest of the array one place forward.

example:



        
5条回答
  •  误落风尘
    2021-02-12 11:32

    Additionally, if you want to add n numbers of rows with zero values. you can create a zero array and use hstack:

    zero_array = np.zeros([n])
    new = np.hstack([zero_array,old_array])
    

提交回复
热议问题