In [2]:
%matplotlib inline
import pandas as pd
In [3]:
from IPython.core.display import HTML
css = open('style-table.css').read() + open('style-notebook.css').read()
HTML('<style>{}</style>'.format(css))
Out[3]:
In [4]:
titles = pd.DataFrame.from_csv('data/titles.csv', index_col=None)
titles.head()
Out[4]:
In [5]:
cast = pd.DataFrame.from_csv('data/cast.csv', index_col=None)
cast.head()
Out[5]:
In [6]:
len(cast)
Out[6]:
In [ ]:
In [7]:
titles.sort('year').head(2)
Out[7]:
In [ ]:
In [8]:
len(titles[titles['title'] == "Hamlet"])
Out[8]:
In [ ]:
In [9]:
len(titles[titles['title'] == "North by Northwest"])
Out[9]:
In [ ]:
In [10]:
titles[titles['title'] == "Hamlet"].sort("year").head(1)
Out[10]:
In [ ]:
In [11]:
titles[titles.title == 'Treasure Island'].sort("year")
Out[11]:
In [ ]:
In [12]:
len(titles[titles.year ==1950])
Out[12]:
In [ ]:
In [13]:
len(titles[titles.year ==1960])
Out[13]:
In [ ]:
In [14]:
len(titles[(titles.year >=1950) & (titles.year <=1959)])
# t = titles
# len(t[(t.year >= 1950) & (t.year <= 1959)])
Out[14]:
In [ ]:
In [15]:
titles[titles.title == "Batman"].year
Out[15]:
In [ ]:
In [27]:
len(cast[cast["title"] == "Inception"])
Out[27]:
In [ ]:
In [26]:
len(cast[cast.n.isnull()][cast["title"] == "Inception"])
Out[26]:
In [ ]:
In [33]:
len(cast[cast.n.notnull()][cast.title == "Inception"])
Out[33]:
In [ ]:
In [34]:
cast[cast.title == "North by Northwest" ][cast.n.notnull()].sort('n')
Out[34]:
In [ ]:
In [36]:
cast[(cast.title == "Sleuth") & (cast.year == 1972)][cast.n.notnull()].sort("n")
Out[36]:
In [ ]:
In [37]:
cast[(cast.title == "Sleuth") & (cast.year == 2007)][cast.n.notnull()].sort("n")
Out[37]:
In [ ]:
In [38]:
len(cast[(cast.title == "Hamlet") & (cast.year == 1921)][cast.n.notnull()])
Out[38]:
In [ ]:
In [41]:
len(cast[(cast.title == "Hamlet") & (cast.year == 1996)][cast.n.notnull()])
Out[41]:
In [ ]:
In [45]:
len(cast[cast.character == "Hamlet"])
Out[45]:
In [ ]:
In [44]:
len(cast[cast.character == "Ophelia"] )
Out[44]:
In [ ]:
In [46]:
len(cast[cast.character == "The Dude"] )
Out[46]:
In [ ]:
In [47]:
len(cast[cast.character == "The Stranger"] )
Out[47]:
In [ ]:
In [52]:
c = cast
c = c[c.name == 'Sidney Poitier']
len(c)
Out[52]:
In [ ]:
In [53]:
c = cast
c = c[c.name == 'Judi Dench']
len(c)
Out[53]:
In [ ]:
In [55]:
c = cast
c = c[(c.name == 'Cary Grant') & (c.n == 2) &(c.year >=1940) & (c.year<1950)].sort("year")
c
Out[55]:
In [ ]:
In [57]:
c = cast
c = c[(c.name == 'Cary Grant') & (c.n == 1) &(c.year >=1940) & (c.year<1950)].sort("year")
c
Out[57]:
In [ ]:
In [ ]:
c = cast
c = c[(c.name == 'Cary Grant') & (c.n == 1) &(c.year >=1940) & (c.year<1950)].sort("year")
c
In [ ]:
In [59]:
len(cast[(cast.type == "actress") &(cast.year >=1940) & (cast.year <1950)])
Out[59]:
In [ ]:
In [60]:
len(cast[(cast.n==1)&(cast.year <=1980)])
Out[60]:
In [ ]:
In [61]:
len(cast[(cast.n!=1)&(cast.year <=1980)])
Out[61]:
In [ ]:
In [64]:
len(cast[(cast.n.isnull())&(cast.year <=1980)])
Out[64]:
In [ ]: