title: how to use python to extract conditional data from excel
body: <p>I am trying to read data from csv and compare value from ‘Sentiment’ column against</p>
  <pre><code>df1 = pd.read_csv('C:\\Python\\hack\\customer_reviews_further_analysis3.csv')
  df2 = pd.read_csv('C:\\Python\\hack\\Bank_Offers_data.csv')
  
  cols = ['CustomerRating','CustomerFeedback', 'Sentiment','Bank','Card','TravelnHotel','Rewards','Lifestyle','Charge']
  
  quotes=[]
  
  if ((df1.Sentiment == 1) | (df1.Sentiment == 4)):
      if((df1.CustomerRating == 5) | (df1.CustomerRating == 4)):
          while((df1.TravelnHotel == df2.TravelnHotel) &amp; (df1.Rewards == df2.Rewards) &amp; (df1.Lifestyle == df2.Lifestyle) &amp; (df1.Charge == df2.Charge)):
              continue
          quotes.append(df1['Sentiment','Bank','Card','TravelnHotel','Rewards','Lifestyle','Charge'])
          
  </code></pre>
  
  <pre><code>Error:
  runfile('C:/Python/ProductComparison_10Dec.py', wdir='C:/Python')
  Traceback (most recent call last):
  
    File &quot;C:\Python\ProductComparison_10Dec.py&quot;, line 29, in &lt;module&gt;
      if ((df1.Sentiment == 1) | (df1.Sentiment == 4)):
  
    File &quot;C:\Users\176226\Anaconda3\lib\site-packages\pandas\core\generic.py&quot;, line 1479, in __nonzero__
      f&quot;The truth value of a {type(self).__name__} is ambiguous. &quot;
  
  ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
  </code></pre>
  <p>Referred previous solution on:
  <a href="https://stackoverflow.com/questions/36921951/truth-value-of-a-series-is-ambiguous-use-a-empty-a-bool-a-item-a-any-o">Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()</a>
  However this did not help</p>