Numpy np.where multiple condition
<p>I need to work with multiple condition using numpy.</p>

<p>I'm trying this code that seem to work. </p>

<p>My question is: There is another alternative that can do the same job? </p>

<pre><code>Mur=np.array([200,246,372])*pq.kN*pq.m
Mumax=np.array([1400,600,700])*pq.kN*pq.m
Mu=np.array([100,500,2000])*pq.kN*pq.m
Acreq=np.where(Mu&lt;Mur,0,"zero")
Acreq=np.where(((Mur&lt;Mu)&amp;(Mu&lt;Mumax)),45,Acreq)
Acreq=np.where(Mu&gt;Mumax,60,Acreq)
Print(Acreq)
['0' '45' '60']
</code></pre>

<p>you can use Pandas's <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.cut.html" rel="nofollow">pd.cut()</a> method:</p>

<p>generate random series of integers:</p>

<pre><code>In [162]: import pandas as pd

In [163]: s = pd.Series(np.random.randint(-3,10, 10))

In [164]: s
Out[164]:
0    6
1   -3
2    6
3    6
4    7
5    7
6    3
7   -2
8    9
9    1
dtype: int32
</code></pre>

<p>categorize them:</p>

<pre><code>In [165]: pd.cut(s, bins=[-np.inf, 2, 5, np.inf], labels=['0', '45', '60'])
Out[165]:
0    60
1     0
2    60
3    60
4    60
5    60
6    45
7     0
8    60
9     0
dtype: category
Categories (3, object): [0 &lt; 45 &lt; 60]
</code></pre>

python numpy where