title: Comparing values of a single column of pandas dataframe in python (transforming perl to python code)
body: <p>I am trying to convert a perl code to python for simple multiplications of columns by some constants.
  I've created a pandas dataframe with multiple columns of float values.
  Here is the example of the components.csv file.</p>
  
  <pre><code>      NA  MULT   NOA   NOB  CHARGE   EX
  0    8.0   1.0  24.0  24.0     0.0  1.0
  1    8.0   1.0  24.0  24.0     0.0  1.0
  2    8.0   1.0   6.0   6.0     0.0  1.0
  3   20.0   1.0  18.0  18.0     0.0  1.0
  4   23.0   1.0  21.0  21.0     0.0  1.0
  5   26.0   1.0  24.0  24.0     0.0  1.0
  6   11.0   1.0  13.0  13.0     0.0  0.0
  7   16.0   1.0  19.0  19.0     1.0  0.0
  8    1.0   1.0   4.0   4.0    -1.0  0.0
  9   17.0   1.0  23.0  23.0     0.0  0.0
  10   1.0   1.0   4.0   4.0     0.0  0.0
  11   1.0   1.0   4.0   4.0     0.0  0.0
  </code></pre>
  
  <p>The initial parameters are:</p>
  
  <pre><code>$A1 = 9.3692400791;
  $A2 = 9.4492960287;
  $B  = 3.8320915550;
  $C  = 9.5936653352;
  $D  = 1.8739215238;
  $E  = 2.4908584058;
  </code></pre>
  
  <p>The expected output is a single column (d5):</p>
  
  <pre><code>Df5
  -0.2249
  -0.2249
  -0.0562
  -0.1686
  -0.1968
  -0.2249
  -0.1218
  -0.1780
  -0.0384
  -0.2155
  -0.0375
  -0.0375
  </code></pre>
  
  <p>After parsing into a dataframe by using:</p>
  
  <pre><code>pd.set_option('precision', 8)
  df = pd.read_csv("unscaled_components_delimit.csv", delimiter= ",", header=0)
  </code></pre>
  
  <p>I've got multiple conditions to check, for example the following script:</p>
  
  <pre><code>if (df['NA'] &gt; 1).any():
      print(True)
  elif (df['NA'] == 1).any():
      print(False)
  </code></pre>
  
  <p>However the code above, prints only a single value of True, even though there are multiple values of 1.0 at the column with header NA, that means that it does not pass to the second elif. I used the function any() , and maybe another function should be used which I am currently not aware of.
  Hence, might someone suggest a solution for that?</p>
  
  <p>The goal, is to compare each element of column (header NA) with number 1 (larger or equal).
  Then, perform some actions with other conditions for the other columns.</p>
  
  <p>I would be grateful for any help or suggestion.</p>
  
  <p>For more clarity, the following code contains the final desired code with all required conditions:</p>
  
  <pre><code>if (df['NA'] &gt; 1).any():
      if (df['MULT'] == 1).any():
          if ((df['NOB'] != 1).any() or (df['NOB'] ==1).any()):
              d5 = -A1*df['NOB']
          elif((df['NOB'] == 1).any()):
              d5 = -E*df['NOB']
      else:
          d5 = -A2*df['NOB'] - B*(df['NOA']-df['NOB'])
  
  elif (df['NA'] == 1).any():
      if (df['MULT'] == 1).any():
          if ((df['EX'] == 0).any() and (df['NOB'] == 4).any() and (df['CHARGE'] == 0).any()):
              d5 = -A1*df['NOB']
          elif((df['NOB'] != 1).any() or ((df['NOB'] == 1).any() and (df['EX'] != 0).any() )):
              d5 = -C*df['NOB']
          elif((df['NOB'] == 1).any() and (df['EX'] == 0).any()):
              d5 = -E*df['NOB']
      else:
          d5 = -C*df['NOB'] - D*(df['NOA']-df['NOB'])
  </code></pre>
  
  <p>The original perl code is the following ($nh is not needed, hlc in perl is the d5 in python):</p>
  
  <pre><code> if ($na &gt; 1) {
                      if ($mult == 1) {
                              if (($nob != 1) || (($nob == 1) &amp;&amp; ($nh != 0))) {
                                      $hlc = -$A1 * $nob;
                              }
                              elsif (($nob == 1) &amp;&amp; ($nh == 0)) {
                                      $hlc = -$E *$nob;
                              }
                      }
                      else {
                              $hlc = -$A2 * $nob - $B * ($noa - $nob);
                      }
              }
  
              ### HLC for atomic species ###
              elsif ($na == 1) {
                      if ($mult == 1) {
  
                              if (($ex == 0) &amp;&amp; ($nob == 4) &amp;&amp; ($charge == 0)) {
                                      $hlc = -$A1 * $nob;
                              }
                              elsif (($nob != 1) || (($nob == 1) &amp;&amp; ($ex != 0))) {
                                      $hlc = -$C * $nob;
                              }
                              elsif (($nob == 1) &amp;&amp; ($ex == 0)) {
                                      $hlc = -$E *$nob;
                              }
                      }
                      else {
                               $hlc = -$C * $nob - $D * ($noa - $nob);
                      }
              }
  </code></pre>