title: Pandas - ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(),
body: <p>I am trying to do a simple apply function over a data frame as follows:</p>
  <pre><code>titanic = pd.read_csv(&quot;/home/myuser/Downloads/titanic_train.csv&quot;)
  
  X_train = titanic.drop([&quot;Survived&quot;, &quot;PassengerId&quot;], axis=1)
  Y_train = titanic[&quot;Survived&quot;]
  X_test = titanic_test.drop([&quot;PassengerId&quot;], axis=1)
  
  def calc_dist(row, x):
      return 1.0
  for index, test_row in df.iterrows():
      distances = X_train.apply(calc_dist, args=(test_row), axis=1)
  </code></pre>
  <p>Here above, I am not yet calculating any distance but just trying to <code>apply()</code> function stub. I am testing out the function and for this test, the <code>distances</code> will have a series, all <code>1.0</code> floats.</p>
  <p>But I am getting the following error:</p>
  <pre><code>---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-122-e4ef82dbd06e&gt; in &lt;module&gt;
        2     return 1.0
        3 for index, test_row in df.iterrows():
  ----&gt; 4     distances = X_train.apply(calc_dist, args=(test_row), axis=1)
  .
  .
  .
  .
  
  
  ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
  </code></pre>
  <p>Any help is appreciated.</p>