Python Forum
Extract value - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Extract value (/thread-6104.html)



Extract value - Schwarzschild - Nov-06-2017



Hi, I am new in python coding.
I would like to extract parameters for my one value from a list of data which I import to code.
The data looks like:
A B C
-0.074172 -0.090626 0.172934
-0.074172 -0.106671 0.382728
-0.074172 -0.879317 0.827223
0.201498 -0.734963 0.558397
0.201498 -0.558711 0.128794
0.201498 -0.887449 0.839778
0.201498 -0.235678 0.392587
1.563307 1.887411 1.196748
1.563307 1.186415 0.848246
1.563307 1.745578 1.445879
First of all I used all data to make a plot but now I would like to do a plot but only for 0.201498 and parameters for it.


RE: Extract value - sparkz_alot - Nov-06-2017

What have you tried. Be sure and post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode Help for instructions.


RE: Extract value - j.crater - Nov-06-2017

Hi, welcome to Python and the forums!
In what format is your list of data.. csv, or txt...? Depending on that, you may need to do some data/container manipulation first.
Assuming you have a list of elements, the index() method will return index of the desired element in that list.
However, you have 3 lines in which 0.201498 appears, so if you need all of them, you can get the indexes by using list comprehension:
 
indexes = [i for i, x in enumerate(list_of_values) if x == 0.201498]