Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Extracting a column out

I have a list of array of the form.

params = [[array([7.30946927, 2.40445369])],
 [array([7.30886254, 2.40241312])],
 [array([7.21275251, 2.09358208])],
 [array([7.61757898, 0.15745312])],
 [array([7.76890152, 2.70100186])],
 [array([7.82943027, 2.39066977])],
 [array([7.20117715, 2.05259557])],
 [array([7.21455828, 2.09081677])],
 [array([7.46129784, 1.9455824 ])]]

I want to extract out the first element (7.3, 7.3 etc) into a new array that I want to use for plotting.

I have managed to convert this list into an array.
PN = np.array(fit_params)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

But how do I extract the first column? PN[:,0] doesn’t work? I want an array of all the first column elements into one variable.

>Solution :

values = []
for i in params :
    values.append(i[0][0])

print(values)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading