2

I have a graph (please see the attached pict) plotted from a data frame (tsv) that looks like this.

Graph Current vs Z

Time (s)   Current      Current1        X         Y         Line                                                              
0.000000  -5.429863e-08  6.707978e-12  2.750966  6.000009   1.0 -31.771946   
0.001032  -5.352960e-08  7.718102e-11  2.750966  6.000009   1.0 -36.043933   
0.002064  -5.410637e-08  8.166567e-11  2.750966  5.999665   1.0 -40.368444   
0.003096  -5.359368e-08  1.034482e-10  2.750966  5.999665   1.0 -44.803840   
0.004128  -5.740678e-08  1.281138e-10  2.750966  5.999322   1.0 -49.361793   
...                 ...           ...       ...       ...   ...        ...   
56.740393 -5.856032e-08  2.812325e-10  2.750966  5.999665   3.0   6.757639   
56.741425 -5.378594e-08  2.860375e-10  2.750966  5.999665   3.0   2.508996   
56.742457 -5.215176e-08  2.748259e-10  2.750966  5.999665   3.0  -1.762991   
56.743489 -5.266444e-08  2.745055e-10  2.750966  5.999322   3.0  -6.064157   
56.744521 -5.253627e-08  2.857171e-10  2.750616  5.999322   3.0 -10.458701   

           FeedbackType        V2        dt     Amplitude        V1         Z  
Time (s)                                                                       
0.000000            0.0  0.600005  0.001033  1.255979e-09  0.199882  0.476397  
0.001032            0.0  0.600005  0.001032  1.217920e-09  0.199882  0.479176  
0.002064            0.0  0.600005  0.001032  1.173518e-09  0.199882  0.482302  
0.003096            0.0  0.600005  0.001032  1.132287e-09  0.199882  0.485775  
0.004128            0.0  0.600005  0.001032  1.102383e-09  0.199882  0.489248  
...                 ...       ...       ...           ...       ...       ...  
56.740393           8.0  0.600005  0.001032  1.271384e-09  0.199882  8.841045  
56.741425           8.0  0.600005  0.001032  1.247824e-09  0.199882  8.841740  
56.742457           8.0  0.600005  0.001032  1.213842e-09  0.199882  8.842782  
56.743489           8.0  0.600005  0.001032  1.169893e-09  0.199882  8.843824  
56.744521           8.0  0.600005  0.001032  1.125944e-09  0.199882  8.845213  

[54986 rows x 12 columns]

The graph was plotted by limiting x and y value.

plt.xlim (8.50, 8.522)
plt.ylim (-0.05e-8, 0.73e-8)

I would like to know is there any way to figure out the location of the data points used in the graph? (For example, I want to know in which row that Z value of 8.513517 is located). Should I add index number and locate the data point manually?

Thanks.

esqew
  • 42,425
  • 27
  • 92
  • 132
pretzel
  • 21
  • 1
  • The question maybe is _why_ do you need to know the row? What would you do with that information? – AKX Oct 18 '22 at 11:40
  • Does this help [How to find the row with the closest value to a given float in pandas](https://stackoverflow.com/questions/60116838/how-to-find-the-row-with-the-closest-value-to-a-given-float-in-pandas) – DarrylG Oct 18 '22 at 11:45
  • @AKX I want to know the location (rows) so that I can extract the data from that specific location and combine it with another data to draw different plot. – pretzel Oct 18 '22 at 11:59
  • Right. Then please see the link in @DarrylG's comment – you'd ordinarily just do `df[df.Z == 1234]`, but because floats are floats, that comparison may not hold true. – AKX Oct 18 '22 at 12:14
  • Please provide enough code so others can better understand or reproduce the problem. – Community Oct 18 '22 at 12:20
  • @DarrylG Thanks, it partially solved the problem as now I know the exact max and min value for the x-axis. Then, I tried to use df.loc[df['Z'] == 8.522895e+00] to find the rows at which that specific value of Z is located but it yielded no result. Do you have any suggestions? – pretzel Oct 18 '22 at 13:32
  • @AKX Is running df[df.Z == 1234] supposed to give you the location (row) of that specific Z value? I tried it with Z = 8.522895 but it did not generate any results. – pretzel Oct 18 '22 at 13:39
  • @pretzel No, it will give you the row(s) itself, but that should do fine if you want the data: `df[df.Z == 1234][['X', 'Z']]` for instance... – AKX Oct 18 '22 at 13:59

0 Answers0