title: Using csv data file for reducing the length of the code gets error a.all() or a.any()
body: <p>I wrote the following code. for fast running and briefing, I write a <code>31*31</code> matrix in a <code>csv</code> file as we can see in <code>CovSN</code>. I wonder how should I do it for <code>xx</code> and <code>yy</code> to remove <code>for loop</code> and <code>f_list[]</code> in <code>def SN(Om, A, al, M):</code> to write something like:</p>
  
  <pre><code>def dL(Om, A, al, M):   
      q_sn = quad(ant, 0, za, args=(Om,  A, al))[0]      
      h = 5 * log10( (1+za) * q_sn)  
      fn = (mua - M - h)            
      return fn
  
  def SN(Om, A, al, M):
       sn= np.dot(dL(Om, A, al, M), np.dot(cova, dL(Om, A, al, M))
       return sn
  </code></pre>
  
  <p>But Python gets error when I do these replacement</p>
  
  <pre><code>if (b != Inf and a != -Inf): alueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). &gt;&gt;&gt;
  </code></pre>
  
  <p>the code is</p>
  
  <pre><code>import numpy as np
  from math import *
  from scipy.integrate import quad
  from scipy.integrate import odeint
  import pandas as pd
  
  xx=np.array([0.01,0.012,0.014,0.016,0.019,0.023,0.026,0.031,0.037,0.043,
              0.051,0.06,0.07,0.082,0.097,0.114,0.134,0.158,0.186,0.218,
              0.257,0.302,0.355,0.418,0.491,0.578,0.679,0.799,0.94,1.105,1.3])
  
  yy=np.array([32.95388698,33.87900347,33.84214074,34.11856704,34.59344598,
              34.93902653,35.25209633,35.74850165,36.06978761,36.43457047,
              36.65111059,37.15801411,37.43017325,37.95661635,38.25325404,
              38.61286934,39.06785071,39.3414019,39.79214362,40.1565346,
              40.56495606,40.90528778,41.42141744,41.79092346,42.23146107,
              42.61704707,43.05273149,43.50415083,43.97257341,44.51408758,44.82186746])   
  
  cov = pd.read_csv('covSN.csv', header=None)
  cova = cov.as_matrix(columns=None)
  CovSN = np.asmatrix(cova)
  
  def ant(z, Om, A, al):
      return (Om * (1 + z)**3 + (1 - Om)*(A+(1+A)*(1+z)**al)**(0.5))**(-0.5)  
  
  def dL(n, Om, A, al, M):   
      q_sn = quad(ant, 0, xx[n], args=(Om,  A, al))[0]      
      h = 5 * log10((299000/70) * (1+xx[n]) * q_sn)  
      fn = (yy[n] - M - h)            
      return fn
  
  def SN(Om, A, al, M):
      f_list = []
      for i in range(31):     
              f_list.append(dL(i, Om, A, al, M))
      rdag = [f_list]    
      rmat = [[f] for f in f_list] 
      m1 = np.dot(rdag,CovSN)         
      m2 = np.dot(m1,rmat)            
      x2_SN = np.linalg.det(m2) * 0.000001
      return x2_SN
  
  print(SN(0.25, 1, -0.9, 0.02))
  </code></pre>