SciSharp/Numpy.NET

How can I extract NDarry's colum

Wuhaotiandl opened this issue · 3 comments

the shape of a NDarray is (10, 20)
I know that I can extract row by NDarray1[rowidx] but, how can I extract column ?

henon commented

This is basic numpy knowledge which you find on their excellent documentation on numpy.org. In any case the answer is easy. Here is how you do it in Python:

>>> import numpy as np
>>> np.arange(10).reshape(2,5)
array([[0, 1, 2, 3, 4],
       [5, 6, 7, 8, 9]])
>>> a=np.arange(10).reshape(2,5)
>>> a[:, 1]
array([1, 6])
>>>

and this is how you do it in C#

var a=np.arange(10).reshape(2,5);
var col1=a[":, 1"];
// or
var x=3
var colx=a[Slice.All, Slice.Index(x)];

Thank u so much. I know how to do it in python, but don't know how to implement it in C#