Python- obtain maximum value in an interval

Question!

I have a .CSV file (a list) that contains 43142 rows and 2 columns.

When plotting the list's values x vs y:

    import numpy as np
    import matplotlib.pyplot as plt

    filename=np.genfromtxt(list.CSV,delimiter=',')
    plt.plot(filename[:,0],filename[:,1])

I get a graph which has multiple maxima values and looks like this: x vs y values of list.CSV

What i want to do is, given an aproximate interval in the x values in which the peaks are positioned, find the maximum values and the corresponding indices on the list.

e.g if there's a maximum y value in the interval x=(2720,2730) (refer to figure 2), i want to find the exact index in which the value is maximum.



Answers

If you have a range xmin < x < xmax then this should work (taking x=filename[:,0] and y=filename[:,1]) :

idx = np.where(y==np.max(y[(x>xmin)&(x<xmax)]))[0][0]

This will return a single index corresponding to the maximum y value in the given range.



To make sure all fields are filled before submission of the form:

<input type="radio" required>

The ' required ' attribute makes sure all fields are filled before the form can be submitted.



I don't have the privalage to comment but you can use the required field as follows

 <input type="radio" name="question-1-answers" id="question-1-answers-A" value="A" required=true />

using this way the user will have to click all the required fields before submitting a form.



This video can help you solving your question :)
By: admin