擅长:python、mysql、java
<p>您可以使用<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html" rel="nofollow noreferrer">^{<cd1>}</a>,它返回一个包含行和列索引的元组,其中包含您的值。然后您可以从中只选择行。在</p>
<pre><code>df = pd.DataFrame(np.random.randint(0,100,size=(4, 4)), columns=list('ABCD'))
indices = np.where(df.values == 20)
rows = indices[0]
if len(rows) != 0:
print(rows[0])
</code></pre>