Untitled0



In [15]:
import pandas as pd
import numpy as np
import os as os

In [7]:
from datetime import datetime
now = datetime.now()

In [8]:
now


Out[8]:
datetime.datetime(2015, 2, 16, 16, 57, 13, 791155)

In [30]:
df = pd.read_csv("data.csv")
df.head()


Out[30]:
year award won name movie
0 1927/28 (1st) ACTOR False Richard Barthelmess The Noose
1 1927/28 (1st) ACTOR True Emil Jannings The Last Command
2 1927/28 (1st) ACTRESS False Louise Dresser A Ship Comes In
3 1927/28 (1st) ACTRESS True Janet Gaynor 7th Heaven
4 1927/28 (1st) ACTRESS False Gloria Swanson Sadie Thompson

In [36]:
actors = df[df.award == 'ACTOR']
actors.head()


Out[36]:
year award won name movie nth
0 1927/28 (1st) ACTOR False Richard Barthelmess The Noose 1
1 1927/28 (1st) ACTOR True Emil Jannings The Last Command 1
35 1928/29 (2nd) ACTOR False George Bancroft Thunderbolt 2
36 1928/29 (2nd) ACTOR True Warner Baxter In Old Arizona 2
37 1928/29 (2nd) ACTOR False Chester Morris Alibi 2

In [34]:
df['nth'] = df['year'].map(lambda x: int(x.split("(")[1].split(")")[0][:-2]))
df.head()


Out[34]:
year award won name movie nth
0 1927/28 (1st) ACTOR False Richard Barthelmess The Noose 1
1 1927/28 (1st) ACTOR True Emil Jannings The Last Command 1
2 1927/28 (1st) ACTRESS False Louise Dresser A Ship Comes In 1
3 1927/28 (1st) ACTRESS True Janet Gaynor 7th Heaven 1
4 1927/28 (1st) ACTRESS False Gloria Swanson Sadie Thompson 1

In [44]:
actors.groupby('name')


Out[44]:
<pandas.core.groupby.DataFrameGroupBy object at 0x7f0994a1e410>

In [49]:
actors.to_records(index=False)[0]


Out[49]:
('1927/28 (1st)', 'ACTOR', False, 'Richard Barthelmess', 'The Noose', 1)