Finding value of another attribute given an attribute
<p>I have a CSV that has multiple lines, and I am looking to find the <code>JobTitle</code> of a person, given their name. The CSV is now in a DataFrame <code>sal</code> as such:</p>

<pre><code>id    employee_name    job_title
1     SOME NAME        SOME TITLE    
</code></pre>

<p>I'm trying to find the <code>JobTitle</code> of some given persons name, but am having a hard time doing this. I am currently trying to learn pandas by doing crash courses and I know I can get a list of job titles by using <code>sal['job_title']</code>, but that gives me an entire list of the job titles.</p>

<p><strong>How can I find the value of a specific person?</strong></p>

<p>You need <a href="http://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing" rel="nofollow"><code>boolean indexing</code></a>:</p>

<pre><code>sal[sal.employee_name == 'name']
</code></pre>

<p>If need select only some column, use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.ix.html" rel="nofollow"><code>ix</code></a> with <code>boolean indexing</code>:</p>

<pre><code>sal.ix[sal.employee_name == 'name', 'job_title']
</code></pre>

<p>Sample:</p>

<pre><code>sal = pd.DataFrame({'id':[1,2,3],
                   'employee_name':['name','name1','name2'],
                   'job_title':['titleA','titleB','titleC']},
                    columns=['id','employee_name','job_title'])

print (sal)
   id employee_name job_title
0   1          name    titleA
1   2         name1    titleB
2   3         name2    titleC

print (sal[sal.employee_name == 'name'])
   id employee_name job_title
0   1          name    titleA

print (sal.ix[sal.employee_name == 'name', 'job_title'])
0    titleA
Name: job_title, dtype: object
</code></pre>

python csv pandas