So I have values given below. Here Index is frame numbers and A is the value related to that frame number.
Index A
15 21.0
21 0.0
28 18.0
35 0.0
43 21.0
52 0.0
55 nan
60 nan
63 nan
64 nan
69 16.0
70 nan
72 15.0
79 nan
82 nan
91 0.0
94 8.0
99 0.0
100 0.0
106 15.0
113 0.0
119 nan
123 0.0
133 22.0
141 nan
142 10.0
148 0.0
152 8.0
154 nan
158 16.0
Using the above values, I am trying to plot a graph which gives me Maxima and Minima. Now there are some maxima and minima values that are very close and I want to combine it to one single point. I have attached an image of the graph.
Edit 1:- My expected output is, as shown in the 4th plot in the figure below, I want it to be a continuous graph and combine very close minima and maxima values to one value. Image of the Graph
Edit 2:- My maxima values are as follows. I want to combine Index 69 and 72 as one single point as they are very close.
Index A
15 21.0
28 18.0
43 21.0
55 nan
63 nan
69 16.0
72 15.0
82 nan
94 8.0
106 15.0
119 nan
133 22.0
142 10.0
152 8.0
158 16.0