title: Pandas Column Manipulation
body: <p>I am trying to manipulate a pandas df so I can count the frequency of occurrences of a data point in one column after a specific occurrence another column. My psuedo code below probably sums it up best. Any help would be much appreciated!</p>
  
  <pre><code>import datetime
  import time
  import pandas as pd
  
  # Set number of rows to skip
  rows_to_skip = 0
  # Rows to use after skipped rows
  rows_to_use = 10000
  
  # Read the file  (Adjust arguments accordingly)
  data = pd.read_csv('example.csv',skiprows=rows_to_skip, error_bad_lines=False, nrows=rows_to_use, low_memory=False)
  
  # Add headers when skipping rows
  data.columns = ["X","Y","Z"]
  
  # Psuedo Code Below
  
  for variable in data['X']:
      if variable &gt; 0:  
          # Count number of times the following conditions are met in all subsequent rows:
          condition 1 ) Y &gt; 0
          condition 2 ) Z &lt;= Z of the row where variable was &gt; 0
  
         # Then I want to add the total count to a new column, and have it in the same row as X when the "variable" &gt; 0.
  </code></pre>
  
  <p>Any help?     </p>