Season Movie Analysis


In [1]:
import random
import pandas as pd
from plotly.graph_objs import *

Using plotly offline mode


In [2]:
from plotly.offline import init_notebook_mode, iplot, plot
init_notebook_mode(connected=True)


Reading the final dataset


In [4]:
dataset = pd.read_csv('finalDataset.csv')

dataset.head(3)


Out[4]:
TMDB ID IMDB ID TITLE YEAR GENRE RATING RELEASED ACTORS AWARDS COUNTRY LANGUAGE BOX OFFICE ADJ. BOX OFFICE
0 862 tt0114709 Toy Story 1995 Animation, Adventure, Comedy 8.3 22 Nov 1995 Tom Hanks, Tim Allen, Don Rickles, Jim Varney Nominated for 3 Oscars. Another 23 wins & 18 n... USA English 191796233.0 360224189.0
1 8844 tt0113497 Jumanji 1995 Action, Adventure, Family 6.9 15 Dec 1995 Robin Williams, Jonathan Hyde, Kirsten Dunst, ... 4 wins & 9 nominations. USA English, French 100200000.0 188191724.0
2 15602 tt0113228 Grumpier Old Men 1995 Comedy, Romance 6.6 22 Dec 1995 Walter Matthau, Jack Lemmon, Sophia Loren, Ann... 2 wins & 2 nominations. USA English 69870000.0 131227103.0

List of Seasons [Spring, Summer, Fall(Autum), Winter] with corresponding months


In [5]:
monthList = ['Mar|Apr|May', 'Jun|Jul|Aug', 'Sep|Oct|Nov', 'Dec|Jan|Feb']

List with

  • First Index - Season Names
  • Second Index - Mean of Adj. Box Office of each season
  • Third Index - Movie Count for each season
  • Fourth Index - Mean rating for each season

In [6]:
finalList = [['Spring', 'Summer', 'Fall(Autumn)', 'Winter'] ,\
             [int(dataset[dataset.RELEASED.str.contains(seasonMonths, na = False)]['ADJ. BOX OFFICE'].mean()) \
                 for seasonMonths in monthList] , \
             [len(dataset[dataset.RELEASED.str.contains(seasonMonths, na = False)]) \
                  for seasonMonths in monthList] , \
             [round(dataset[dataset.RELEASED.str.contains(seasonMonths, na = False)]['RATING'].mean(), 2) \
              for seasonMonths in monthList]]

Function that return dicitonary data to plot the data point


In [7]:
def data_(boxoffice, rating, movieCount, name):
    
    return {
        'x' : [boxoffice],
        'y' : [rating],
        'name' : name,
        'mode' : 'markers',
        'text' : 'Season: ' + name + \
                 '<br>Mean Rating: ' + str(rating) + \
                 '<br>Movie Count: ' + str(movieCount) + \
                 '<br>Mean BoxOffice: ' + str(round(boxoffice/1000000, 2)) + 'M',
        'hoverinfo' : 'text',
        'marker' : {
            'size' : [movieCount],
            'sizemode' : 'area',
            'line' : {
                'width' : 1
            }
    }
}

Adding Data to figure and setting x-axis, y-axis, title, background of layout


In [8]:
figure = {
    'data': [data_(finalList[1][i], finalList[3][i], finalList[2][i], finalList[0][i]) for i in range(4)],
    'layout' : {}
}

figure['layout']['xaxis'] = {'title' : 'Mean Box Office',
                            'titlefont': {
                                'size' : 16, 'family' : 'Droid Sans'
                            },
                            'showline' : True,
                            'ticks' : 'outside',
                            'tickwidth' : 2,
                            'gridcolor' : '#FFFFFF'}

figure['layout']['yaxis'] = {'title' : 'Mean Rating', 
                            'titlefont' : {
                                'size' : 16 , 'family' : 'Droid Sans'
                            },
                            'showline' : True,
                            'ticks' : 'outside',
                            'tickwidth' : 2,
                            'gridcolor' : '#FFFFFF'}

figure['layout']['title'] =  'Season Movie Analysis'
figure['layout']['titlefont'] = {'size' : 20, 'family' : 'Times New Roman'}
figure['layout']['plot_bgcolor'] = 'rgb(223, 232, 243)'

Plotting the figure


In [9]:
# iplot(figure)
plot(figure)


Out[9]:
'file:///Users/shivakumarswamybg/Desktop/Project/temp-plot.html'

In [ ]: