I have periodic data with an index that is a floating point number, for example:
time = [0, 0.1, 0.21, 0.31, 0.40, 0.49, 0.51, 0.6, 0.71, 0.82, 0.93]
voltage = [1, -1, 1.1, -0.9, 1, -1, 0.9,-1.2, 0.95, -1.1, 1.11]
df = DataFrame(data=voltage, index=time, columns=['voltage'])
df.plot(marker='o')
I want to create a function that returns an array of times (indices) with all interpolated points where the voltage values are y_val . For 'boost' , only values are returned where the slope is positive; for 'fall' only values with a negative slope are stored; for 'cross' both return. Therefore, if y_val = 0 and direction = 'cross' , then an array with 10 values will be returned with X values of the intersection points (the first of which is about 0.025), cross(df, y_val, direction='rise' | 'fall' | 'cross')
I thought this could be done using an iterator, but it was interesting if there was a better way to do this.
Thank. I love Pandas and the Pandas community.