给出一个一维 numpy ndarray,如下图所示:

形状为:(9,)
类类型为:
如何对该数据结构进行切片以获得第三列和第四列(宽松地使用术语“列”),如图所示:

请注意,我可以使用转换为 pandas
数据帧来处理此问题,但我的核心问题是我如何对其进行切片使用 numpy 或任何内置的 python 切片函数?
Give a 1-dimensional numpy ndarray as seen in the image below:

The shape is: (9,)
The class type is: <class 'numpy.ndarray'>
How do I slice this data structure so as to get the 3rd and 4th columns (using the term columns loosely) as seen in this image:

Note that I could have used a conversion to pandas
dataframe to handle this but my core question is how can I slice this using numpy or any inbuilt python slicing function?
发布评论
评论(2)
我建议将元组数组转换为数组数组,然后使用 numpy 切片:
I suggest to convert array of tuples to array of arrays then use
numpy
slice:你可以尝试这个
you can try this