title: Modifying Wide Pandas Data frame based on Condition
body: <p>I am attempting to edit values for a wide form of time series data based on a condition in python using the pandas library. The data is satellite observational values on a given date (see photo below). The first column is a unique id and all subsequent columns are date values. This means that each row is a time series for that specific id. </p>
  
  <p>The idea is this:</p>
  
  <p>if <strong>n1</strong> is the current observation and <strong>n2</strong> is the next observation and <strong>n3</strong> is the observation after that then:</p>
  
  <pre class="lang-py prettyprint-override"><code>if ((n2 - n1) &gt; 0.3) and (n3 &gt;= (0.9 * n1)):
      n2 = (n1 + n3) / 2
  </code></pre>
  
  <p>Just to be clear, n1, n2, n3 are the first three values of this data frame, not attributes. For the attached example n1 would be 0.25916876 and n2 would be 0.25916876 and n3 would be 0.23824187.   </p>
  
  <p>How can I modify my Data frame with this rule? Could this be done with list comprehension?  </p>
  
  <p><a href="https://i.stack.imgur.com/aKDKf.jpg" rel="nofollow noreferrer">This is what df looks like</a></p>