title: How do I slice 1 cycle of sine wave using python?
body: <p>I need to do some data analysis by extracting one complete cycle from a sine wave graph.</p>
  
  <p>I have some CSV file consists of like 100K Current and Voltage value. From this CSV file, normally I would plot it and manually extract for one complete cycle. Now I would like to do it using python</p>
  
  <pre><code>import pandas as pd
  
  file_path = "/Users/Fang/workspace_wind/test_cycle/the_data/"
  
  ## read csv file, selecting the first column only that is I(current)
  df = pd.read_csv(file_path+"current1.csv", usecols=[0])
  
  ## find the maximum value, for the index use idxmax()
  max_val = df['I'].idxmax()
  ## find the minimum value, for the index use idxmin()
  min_val = df['I'].min()
  
  
  print max_val
  </code></pre>
  
  <p>I started with this code. So far, I managed to understand how to get the highest value and the lowest value for half the cycle. At first, I want to slice it from the first highest value to the second highest value (peak to peak) for a one complete cycle but since the amplitude is not always the same, this method of mine is not going to work.</p>
  
  <p>This is the example of the CSV file --> <a href="https://drive.google.com/open?id=0B4i3HIPTmP91RlRQLTBKTU5pYTg" rel="nofollow noreferrer">sample</a></p>
  
  <p>The closest that I found so far is this question <a href="https://stackoverflow.com/questions/4381744/how-do-i-determine-the-high-and-low-values-in-a-series-of-cyclic-data">here</a> but I did not really understand it.</p>
  
  <p>Thank you for your help and suggestion.</p>