title: How to count the number of instances between two dates/times
body: <p>Noobie here, so please bear with me. I'll try to make this as concise as possible.</p>
  
  <p>I have two dataframes:</p>
  
  <p><code>df2</code>: Consists of unique <code>visit number</code> for each person, time the person arrived to our store, time the person departure departed from our store</p>
  
  <p><code>df1</code>: Is a subset of <code>visit numbers</code> from <code>df2</code> (as well as some other data not in <code>df2</code>). </p>
  
  <p>Every <code>visit number</code> in <code>df1</code> is in <code>df2</code>, but the reverse is not true.</p>
  
  <p>What i need to do is:
  For each <code>visit number</code> in <code>df1</code>, determine how many people total were present when the person from df1 arrived.</p>
  
  <p>The way I thought about this problem is as follows (I provided some code below):
  1. Iterate through <code>df1</code>
  2. Take the <code>visit ID</code> from <code>df1</code>
  3. Apply this <code>visit ID</code> to <code>df2</code> to get that person's arrival time
  4. Create a <code>mask</code> using that arrival time 
  5. Apply that <code>mask</code> to <code>df2</code> then just count the number of rows</p>
  
  <pre><code>for index, row in df1.iterrows():
      visit_id = row['ID_number']
      df2row = df2[(df2['ID_number'] == visit_id
      arrival_time = df2row['Arrival_Date/Time']
      mask = (df2['Arrv Date/Time'] &lt; arrival_time) &amp; (df2['Disch 
      Date/Time'] &gt; arrival_time)
      total_customers = len(df2.loc(mask))
  </code></pre>
  
  <p>However, when i run this code i get an error:</p>
  
  <pre><code>ValueError: Can only compare identically-labeled Series objects
  </code></pre>
  
  <p>This is related to the <code>mask</code> i created.</p>
  
  <p>I've done some searching, and it seems like this error has something to do with? Indexing? but I can't seem to make my code work. I've tried the advice in the several other threads to no avail.</p>
  
  <p>Any advice, or other ways to think about this problem would be much appreciated!!!!</p>
  
  <p>Thanks,</p>
  
  <p>noob</p>