I have a data array to which I have inserted a column with values starting from 0. So now my data contains all float values.
After some processing I have a array ARR which contains values from my 1st column. Using these ARR values (or positions) I want to extract the remaining columns to a new array using Numpy.
import numpy as np
import io
data =io.StringIO("""
ID,1,2,3
5362,0.97,-0.40,-0.76
485,-0.65,0.53,0.62
582,0.04,0.99,0.76
99,0.77,0.53,0.39
75,-0.44,0.52,0.85
474,0.35,0.8,0.13
594,-0.29,0.03,0.74
597,0.96,-0.35,0.59
124,0.73,0.61,0.76
635,0.88,0.96,-0.98
7894,-0.04,0.04,0.52
1268,0.56,0.73,-0.37
38,0.46,0.62,0.73
88,0.02,0.16,0.098
887,0.46,0.65,-0.89
""")
data = np.genfromtxt(data, delimiter=',', skip_header=2, dtype=np.float64)
index = np.arange(data.shape[0]).reshape(-1, 1)
data = np.hstack([index, data])
ARR = [[1.],[2.],[4.],[6.],[7.],[9.]]
Expected Output Like:
I want all the row values at the positions indicated in the ARR. I can also show it as Integer values. I want all the rows at these positions in my data array.
485,-0.65,0.53,0.62
582,0.04,0.99,0.76
75,-0.44,0.52,0.85
594,-0.29,0.03,0.74
597,0.96,-0.35,0.59
635,0.88,0.96,-0.98