Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python, How to fill up a column in an empty numpy array

I would normally go to

http://docs.scipy.org

for this info but their website is down for some reason:/

But how would I be able to fill up an entire column in a numpy matrix?

a = numpy.zeros(shape=(100,10))
a[0] = [1,2,3,4,5,6,7,8,9,0]

fills up a row, but how can you do a column?

like image 526
Sean Avatar asked Aug 03 '26 18:08

Sean


2 Answers

Never too late to answer...

a[:, k] = values
like image 173
dwp4ge Avatar answered Aug 06 '26 08:08

dwp4ge


This fills the same value in all columns:

  array[:, column] = values
like image 45
Saim Yousuf Avatar answered Aug 06 '26 08:08

Saim Yousuf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!