In [1]:
%matplotlib inline
import pandas as pd
import seaborn as sbn
sbn.set()

In [2]:
from IPython.core.display import HTML
css = open('style-table.css').read() + open('style-notebook.css').read()
HTML('<style>{}</style>'.format(css))


Out[2]:

In [3]:
cast = pd.DataFrame.from_csv('data/cast.csv', index_col=None)
cast.head()


Out[3]:
title year name type character n
0 Suuri illusioni 1985 Homo $ actor Guests 22
1 Gangsta Rap: The Glockumentary 2007 Too $hort actor Himself NaN
2 Menace II Society 1993 Too $hort actor Lew-Loc 27
3 Porndogs: The Adventures of Sadie 2009 Too $hort actor Bosco 3
4 Stop Pepper Palmer 2014 Too $hort actor Himself NaN

In [4]:
release_dates = pd.DataFrame.from_csv('data/release_dates.csv', index_col=None,
                                      parse_dates=['date'], infer_datetime_format=True)
release_dates.head()


Out[4]:
title year country date
0 #73, Shaanthi Nivaasa 2007 India 2007-06-15
1 #AnonOccupy: Bio of a Villain 2015 USA 2015-11-05
2 #Beings 2015 Romania 2015-01-29
3 #Ewankosau saranghaeyo 2015 Philippines 2015-01-21
4 #Nerealnaya lyubov 2014 Russia 2014-02-13

In [ ]:

Make a bar plot of the months in which movies with "Christmas" in their title tend to be released in the USA.


In [7]:
stNick = release_dates[release_dates.title.str.contains('Christmas')]
stNick.date.dt.month.value_counts().sort_index().plot(kind='bar')


Out[7]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f6c2bc0d438>

In [ ]:

Make a bar plot of the months in which movies whose titles start with "The Hobbit" are released in the USA.


In [8]:
frodoBaggins = release_dates[release_dates.title.str.startswith('The Hobbit')]
frodoBaggins.date.dt.month.value_counts().sort_index().plot(kind='bar')


Out[8]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f6c2cbbc3c8>

In [ ]:

Make a bar plot of the day of the week on which movies with "Romance" in their title tend to be released in the USA.


In [10]:
ronJeremy = release_dates[release_dates.title.str.contains('Romance')]
ronJeremy.date.dt.dayofweek.value_counts().sort_index().plot(kind='bar')


Out[10]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f6c2c10f940>

In [ ]:

Make a bar plot of the day of the week on which movies with "Action" in their title tend to be released in the USA.


In [11]:
jamesBond = release_dates[release_dates.title.str.contains('Action')]
jamesBond.date.dt.dayofweek.value_counts().sort_index().plot(kind='bar')


Out[11]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f6c2c122908>

In [ ]:

On which date was each Judi Dench movie from the 1990s released in the USA?


In [26]:
judiDench = pd.merge(cast[(cast.name=='Judi Dench')],release_dates[release_dates.country=='USA'])

In [27]:
judiDench[judiDench.year//10 == 199]


Out[27]:
title year name type character n country date
7 GoldenEye 1995 Judi Dench actress M 6 USA 1995-11-17
8 Hamlet 1996 Judi Dench actress Hecuba 12 USA 1996-12-25
13 Jack & Sarah 1995 Judi Dench actress Margaret 3 USA 1996-03-22
17 Mrs Brown 1997 Judi Dench actress Queen Victoria 1 USA 1997-07-18
26 Shakespeare in Love 1998 Judi Dench actress Queen Elizabeth 12 USA 1999-01-08
28 Tea with Mussolini 1999 Judi Dench actress Arabella 2 USA 1999-05-14
34 The World Is Not Enough 1999 Judi Dench actress M 6 USA 1999-11-19
35 Tomorrow Never Dies 1997 Judi Dench actress M 9 USA 1997-12-19

In which months do films with Judi Dench tend to be released in the USA?


In [30]:
judiDench.date.dt.month.value_counts().sort_index()


Out[30]:
1      4
2      3
3      4
4      2
5      4
6      3
7      2
8      1
11    10
12     4
dtype: int64

In [ ]:

In which months do films with Tom Cruise tend to be released in the USA?


In [31]:
tommyC =pd.merge(cast[(cast.name=='Tom Cruise')],release_dates[release_dates.country=='USA'])

In [32]:
tommyC.date.dt.month.value_counts().sort_index()


Out[32]:
1     3
3     1
4     3
5     5
6     7
7     6
8     3
10    2
11    3
12    9
dtype: int64

In [ ]: