You put the NumPy tag in your question, so I assume that you need the NumPy syntax that the answer before mine doesn't use.
If you really want to use NumPy, then you probably don't need the strings in your array, otherwise you will also have to represent your floats as strings.
What you are looking for is NumPy syntax for accessing elements of a 2D array row by row (and exclude the first column) .
This syntax is:
M[row_index,1:]
W / r / t the second scenario of your question is selecting non-contiguous columns :
M[row_index,[0,2]]
A small complication in your Question is that you want to use a row for row_index, so you need to delete the rows (so that you can create a 2D NumPy array of floats), replace them with a numeric string of indices, and then create a lookup table to match strings with numerical indices lines :
>>> import numpy as NP >>>
Second scenario in your question: what if the index column changes?
>>>
doug source share