Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extract value
#1


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.
Reply
#2
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.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
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]
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020