title: How do you achieve the SQL aspects in Python?
body: <p>I have this prompt (shown below). I think I know how to write it in SQL (also shown below but if it's incorrect please tell me). I want to achieve the same result that SQL does but using Python.</p>
  
  <p>Question - Given a set of data, write a function that will parse the data and 1) find the revenue for the given month 2) find the total capacity of the unreserved offices for the given month.</p>
  
  <p>SQL Guess: </p>
  
  <pre><code>SELECT revenue FROM financials WHERE month = "June"
  SELECT SUM(capacity) FROM booking WHERE month = "June" and office_reserved IS NULL
  </code></pre>
  
  <p>I don't have actual data for this so I just made up the column names. The first one is straightforward. The second one is I was thinking there would be a database with columns like month - day - office_reserved - capacity (i.e. like 12 people can sit in the room).</p>
  
  <p>Python Guess:</p>
  
  <pre><code>arr = []
  i = 0
  for i &lt; len(financials):
     if financials.month[i] = "June":
        arr.append(financials.revenue[i])
  i+=1
  
  
  arr = []
  i = 0
  for i &lt; len(booking):
       if booking.month[i] = "June" and office_reserved IS NULL:
            arr.append(booking.capacity[i])
       i+=0
  print(sum(arr))
  </code></pre>
  
  <p>This leads me to believe that SQL is computationally faster than Python in instances of finding data. Python is probably faster in instances of large computations or programs. ??</p>