擅长:python、mysql、java
<p>IIUC您可以使用<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.isin.html" rel="nofollow">^{<cd1>}</a>作为选择值,然后将索引获取到<code>idx</code>,如果索引不是从<code>0</code>开始,请使用<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Index.get_indexer.html" rel="nofollow">^{<cd4>}</a>:</p>
<pre><code>print df
Code
2 F5031032
3 F5546810
4 F117225534
5 F17770
6 F29157
print df['Code'].isin(['F5031032','F17770'])
2 True
3 False
4 False
5 True
6 False
Name: Code, dtype: bool
idx = df[df['Code'].isin(['F5031032','F17770'])].index
print idx
Int64Index([2, 5], dtype='int64')
print df.index.get_indexer(idx)
[0 3]
df1 = df[df['Code'].isin(['F5031032','F17770'])].copy()
df1['Row'] = df.index.get_indexer(idx) + 1
print df1
Code Row
2 F5031032 1
5 F17770 4
</code></pre>