1

I have this data

old= array([[171, 171, 171, ..., 170, 170, 170],
       [171, 171, 171, ..., 170, 170, 170],
       [171, 171, 171, ..., 170, 170, 170],
       ...,
       [ 17,  17,  17, ...,  17,  17,  17],
       [ 17,  17,  17, ...,  17,  17,  17],
       [ 17,  17,  17, ...,  17,  17,  17]], dtype=uint8)

in this data i need to put my external array data points

new= array([ 65, 108, 105,  32, 105, 115,  32, 116, 104, 101,  32,  66, 101,
       115, 116,  32, 105, 110,  32, 116, 104, 101,  32, 119, 111, 114,
       108, 100,  32, 121, 101, 101, 104, 104, 104, 104, 104, 104, 104,
       104])

in the first row of the old array such that output is like

 old= array([[  65, 108, 105,  32, 105, 115,  32, 116, 104, 101,  32,66,101,
       115, 116,  32, 105, 110,  32, 116, 104, 101,  32, 119, 111, 114,
       108, 100,  32, 121, 101, 101, 104, 104, 104, 104, 104, 104, 104,
       104, ..., 170, 170, 170],
       [171, 171, 171, ..., 170, 170, 170],
       [171, 171, 171, ..., 170, 170, 170],
       ...,
       [ 17,  17,  17, ...,  17,  17,  17],
       [ 17,  17,  17, ...,  17,  17,  17],
       [ 17,  17,  17, ...,  17,  17,  17]], dtype=uint8)
Zewo
  • 153
  • 1
  • 12

3 Answers3

1

To replace the first row of your array:

old[0] = new

badarots
  • 36
  • 2
0

I'm assuming you are using numpy? Does

old[0] = new[0]

work? (Assuming you wanted to replace the first row of the old array with the first row of the new array)

digital_hog
  • 202
  • 1
  • 11
0

This should do:

old[0, :len(new)] = new
Quang Hoang
  • 146,074
  • 10
  • 56
  • 74