Y
Y
yuki2020-09-22 08:12:31
Python
yuki, 2020-09-22 08:12:31

How to add an element to a numpy subarray?

There is an array data = . How do I add, say, 0 to the first subarray to get ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
zexer, 2020-09-22
@zexer

A little fiddly, but it works.

import numpy as np
array = np.array()
to = len(a[0])
array = np.insert(array, to, 0, axis=1)
print(array)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question