Selecting data in parenthesis
<p>I have a list of movies in a csv file, 100rows x 1column that looks like this:</p>

<pre><code>1. Mulholland Drive (David Lynch, 2001)
</code></pre>

<p>I'm trying to get rid of the number in the front, put the title, director, and year in each column. I did:</p>

<pre><code>rank = pd.read_csv("/Users/...csv", header = 0) 
rank.columns = ['1']
rank['1'] = rank['1'].str[3:]
</code></pre>

<p>to get rid of all the numbers in the front, so next, I wanted to separate what's in the parenthesis by:</p>

<pre><code>rank = rank[rank.find("(")+1:rank.find(")")]
</code></pre>

<p>but am getting:</p>

<pre><code>AttributeError: 'DataFrame' object has no attribute 'find'
</code></pre>

<p>If they're always definitely in that format, for instance - mocking up a file with just the given example (not that if you've got brackets or commas etc... etc... that don't match the format - this'll break):</p>

<pre><code>rank = pd.read_csv('somefile.csv', header=None, names=['film'])
df = rank.film.str.extract('(?:\d+\.\s+)(.*?)\((.*?),\s+(\d+)\)', expand=True)
</code></pre>

<p>Which'll give you:</p>

<pre><code>                   0            1     2
0  Mulholland Drive   David Lynch  2001
</code></pre>

python pandas slice parentheses