I have two 2D array, x(ni, nj) and y(ni,nj), that I need to interpolate over one axis. I want to interpolate along last axis for every ni.

I wrote

import numpy as np
from scipy.interpolate import interp1d

z = np.asarray([200,300,400,500,600])
out = []
for i in range(ni):
    f = interp1d(x[i,:], y[i,:], kind='linear')
    out.append(f(z))
out = np.asarray(out)


However, I think this method is inefficient and slow due to loop if array size is too large. What is the fastest way to interpolate multi-dimensional array like this? Is there any way to perform linear and cubic interpolation without loop? Thanks.


Question: Calculating pH of diprotic and amphoteric solutions
Answer: 
  First, I have read that $\ce{H2AsO4-}$ is a amphiprotic substances in
  that the dominant reactivity is $$\ce{2H2AsO4- &lt;=&gt; H3AsO4 + HAsO4^{2-}}$$
  
  However, this also seems to be a polyprotic substance. 


The two terms - amphiprotic and polyprotic - aren't mutually exclusive. Amphiprotic substances can simply behave as both Bronsted-Lowry acids and bases in that they can both give up and release hydrogen protons. 

Polyprotic acids have multiple protons to donate. For example, phosphoric acid is triprotic.  

Often times amphiprotic substances will be polyprotic. By nature of being able to lose multiple protons, these substances are also able to gain multiple protons. 


  Why is one $K_a$ value so much larger than the other? If this were a
  amphoteric substance shouldn't the $K_a$ values for both be
  comparable?


Good observation. This lies with Coulomb's law. Think about it. A neutral molecule kicks off a hydrogen proton. Now you have the first conjugate base. The first conjugate base is negatively charged. It also attempts to kick off a proton. Which do you think is easier? Clearly the first process is. Remember that oppositely charged particles attract. This explains why $K_{a1}$ values for polyprotic molecular acids are generally significantly larger than corresponding $K_{a2}$ values. 

Just because the $K_a$ values differ by several orders of magnitude doesn't mean the ion/molecule can't be amphiprotic. 


  Next, I researched how to calculate the $\mathrm{pH}$ value for
  amphiprotic substances, and I found this page that details how to
  do so, and the end result is that the $\mathrm{pH} = \sqrt{K_1 K_2}$.
  Why is the $\mathrm{pH}$ independent of the concentrations?


First, amphiprotic substances don't have $\mathrm{pH}$ values by themselves. In solution, then yes. 


  Further, I also found another page that gets to the same result in a
  different manner. They start by saying:
  
  
    We approximately have the equality relation: $$\ce{[H3AsO4]} = \ce{[HAsO4^{2−}]}$$
  


Regarding the validity of the quoted statement: just note the main reaction stoichiometry. And the magnitude of the main reaction's K. The main K can be found through dividing the Ka of the reactant acid by the Ka of the product acid. 

\begin{aligned}
\ce{H2AsO4^{−} + H2AsO4^{−} &amp;&lt;=&gt; H3AsO4 + HAsO4^2-}\\
K_\mathrm{rxn} &amp;= \frac{K_a(\ce{H2AsO4^{−}})}{K_a(\ce{H3AsO4})}\\
\end{aligned}


  Next, why can't this method of calculating pH in amphoteric acids be
  used for diprotic acids? I found another page that details how to do
  so but even though the reactions are essentially similar to those for
  amphiprotic acids, the end result is different. Why does the same line
  of reasoning as used for deriving the formula for amphoteric
  substances fail for diprotic/polyprotic acids?


For diprotic acid, just keep $K$ value magnitudes in mind. This statement applies to diprotic and polyprotic acids:

$$K_{a2}(\ce{H3AsO4}) = \ce{[HAsO4^{2−}]}$$