0

I have an array value of this form

array([0.69])

Then I would like to extract 0.69 to form an array of this form

array([[0.69],
       [0.69],
       [0.69],
       [0.69],
       [0.69],
       [0.69],
       [0.69]])

I feel that my code is very indirectly and requires many operations.

value = np.array([0.69])
np.array([[value[0].tolist()]] * 7)

Could you please elaborate on how to achieve my goal more directly?

Akira
  • 2,594
  • 3
  • 20
  • 45
  • Have you seen this? https://stackoverflow.com/questions/3459098/create-list-of-single-item-repeated-n-times Seems like using `itertools.repeat()` is faster – sagar1025 Oct 14 '20 at 01:11

1 Answers1

0

I've found that np.full((7, 1), value) is faster and simpler than np.array([[value[0].tolist()]] * 7).

Akira
  • 2,594
  • 3
  • 20
  • 45