title: How can I compare values to each other in two different pandas dataframes
body: <p>I have two different pandas data frames.  One is called 'price' and it has the schema </p>
  
  <pre><code>SKU, price
  </code></pre>
  
  <p>The second data frame is called sales_tracking which contains information about the number of sales for a SKU at a given price.  It's schema is</p>
  
  <pre><code>SKU, price, total_orders, total_visits
  </code></pre>
  
  <p>But when we add a new price point for a SKU in the 'price' data frame, there won't be a matching record in the 'sales_tracking' data frame, at which point I have to add a new entry to the 'sales_tracking' data frame where the total_orders and total_visits is estimated from another data set (we're doing this to estimate conversion rates).</p>
  
  <p>The problem I'm having is being able to check to see if the value for price in the pricing data frame also exists in the sales_tracking data frame. Before doing the comparison, I first create temporary data frames for both the pricing data and the sales data as follows:</p>
  
  <pre><code>sku_specific_sales_records = sales_tracking[sales_tracking['product']==product]
  
  sku_specific_price = sku_specific_price [sku_specific_price ['product']==product]
  </code></pre>
  
  <p>To be clear, both sku_specific_sales_records and sku_specific_price may contain multiple record.  I'm trying to identify the case when there is a row in sku_specific_price where sku_specific_price['price'] is not in sku_specific_sales_records['price'].</p>
  
  <p>I have tried various different things. Something as simple as </p>
  
  <pre><code>if sku_specific_sales_records['price'] == sku_specific_price['price']:
  </code></pre>
  
  <p>doesn't work, I get a ValueError "can only compare identically-labeled Series objects'.  So I also tried</p>
  
  <pre><code>if sku_specific_price['price'].isin(sku_specific_sales_records['price']):
     doTheThingIfTheyMatch
  else:
     doTheOtherThing
  </code></pre>
  
  <p>And that generates a different ValueError: "The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). So I tried using a.bool()</p>
  
  <pre><code>if sku_specific_price['price'].isin(sku_specific_sales_records['price']).bool():
     doTheThingIfTheyMatch
  else:
     doTheOtherThing
  </code></pre>
  
  <p>but that brought me back full circle to the "ValueError: Can only compare identically-labeled Series objects".</p>
  
  <p>Here is a small example illustrating the problem.</p>
  
  <pre><code>import pandas as pd
  sales = pd.DataFrame(columns={'product', 'price', 'sales', 'orders'})
  pricing = pd.DataFrame(columns={'product', 'price'})
  sales.loc[0] = [123, 10, 5, 5]
  sales.loc[1] = [123, 15, 2, 10]
  pricing.loc[0] = [123, 8]
  if sales['price'].isin(pricing['price']):
      print "true"
  else:
      print "false"
  </code></pre>