In [2]:
import pandas as pd
import numpy as nm
import csv
import json
In [3]:
#Open As Text
filename = "tmdb_5000_movies.csv"
file = open(filename, "r", encoding='utf-8')
rtext = ""
for line in file:
rtext += line
file.close()
rtext[:2000]
Out[3]:
'budget,genres,homepage,id,keywords,original_language,original_title,overview,popularity,production_companies,production_countries,release_date,revenue,runtime,spoken_languages,status,tagline,title,vote_average,vote_count\n237000000,"[{""id"": 28, ""name"": ""Action""}, {""id"": 12, ""name"": ""Adventure""}, {""id"": 14, ""name"": ""Fantasy""}, {""id"": 878, ""name"": ""Science Fiction""}]",http://www.avatarmovie.com/,19995,"[{""id"": 1463, ""name"": ""culture clash""}, {""id"": 2964, ""name"": ""future""}, {""id"": 3386, ""name"": ""space war""}, {""id"": 3388, ""name"": ""space colony""}, {""id"": 3679, ""name"": ""society""}, {""id"": 3801, ""name"": ""space travel""}, {""id"": 9685, ""name"": ""futuristic""}, {""id"": 9840, ""name"": ""romance""}, {""id"": 9882, ""name"": ""space""}, {""id"": 9951, ""name"": ""alien""}, {""id"": 10148, ""name"": ""tribe""}, {""id"": 10158, ""name"": ""alien planet""}, {""id"": 10987, ""name"": ""cgi""}, {""id"": 11399, ""name"": ""marine""}, {""id"": 13065, ""name"": ""soldier""}, {""id"": 14643, ""name"": ""battle""}, {""id"": 14720, ""name"": ""love affair""}, {""id"": 165431, ""name"": ""anti war""}, {""id"": 193554, ""name"": ""power relations""}, {""id"": 206690, ""name"": ""mind and soul""}, {""id"": 209714, ""name"": ""3d""}]",en,Avatar,"In the 22nd century, a paraplegic Marine is dispatched to the moon Pandora on a unique mission, but becomes torn between following orders and protecting an alien civilization.",150.437577,"[{""name"": ""Ingenious Film Partners"", ""id"": 289}, {""name"": ""Twentieth Century Fox Film Corporation"", ""id"": 306}, {""name"": ""Dune Entertainment"", ""id"": 444}, {""name"": ""Lightstorm Entertainment"", ""id"": 574}]","[{""iso_3166_1"": ""US"", ""name"": ""United States of America""}, {""iso_3166_1"": ""GB"", ""name"": ""United Kingdom""}]",2009-12-10,2787965087,162,"[{""iso_639_1"": ""en"", ""name"": ""English""}, {""iso_639_1"": ""es"", ""name"": ""Espa\\u00f1ol""}]",Released,Enter the World o'
In [4]:
with open ('tmdb_5000_movies.csv', mode = 'r', encoding='utf-8') as f:
readme = f.read()
print(readme[:1000])
budget,genres,homepage,id,keywords,original_language,original_title,overview,popularity,production_companies,production_countries,release_date,revenue,runtime,spoken_languages,status,tagline,title,vote_average,vote_count
237000000,"[{""id"": 28, ""name"": ""Action""}, {""id"": 12, ""name"": ""Adventure""}, {""id"": 14, ""name"": ""Fantasy""}, {""id"": 878, ""name"": ""Science Fiction""}]",http://www.avatarmovie.com/,19995,"[{""id"": 1463, ""name"": ""culture clash""}, {""id"": 2964, ""name"": ""future""}, {""id"": 3386, ""name"": ""space war""}, {""id"": 3388, ""name"": ""space colony""}, {""id"": 3679, ""name"": ""society""}, {""id"": 3801, ""name"": ""space travel""}, {""id"": 9685, ""name"": ""futuristic""}, {""id"": 9840, ""name"": ""romance""}, {""id"": 9882, ""name"": ""space""}, {""id"": 9951, ""name"": ""alien""}, {""id"": 10148, ""name"": ""tribe""}, {""id"": 10158, ""name"": ""alien planet""}, {""id"": 10987, ""name"": ""cgi""}, {""id"": 11399, ""name"": ""marine""}, {""id"":
In [5]:
#Open As list of lines
filename = "tmdb_5000_movies.csv"
file = open(filename, "r", encoding='utf-8')
lines = [line for line in file]
file.close()
lines[:2]
Out[5]:
['budget,genres,homepage,id,keywords,original_language,original_title,overview,popularity,production_companies,production_countries,release_date,revenue,runtime,spoken_languages,status,tagline,title,vote_average,vote_count\n',
'237000000,"[{""id"": 28, ""name"": ""Action""}, {""id"": 12, ""name"": ""Adventure""}, {""id"": 14, ""name"": ""Fantasy""}, {""id"": 878, ""name"": ""Science Fiction""}]",http://www.avatarmovie.com/,19995,"[{""id"": 1463, ""name"": ""culture clash""}, {""id"": 2964, ""name"": ""future""}, {""id"": 3386, ""name"": ""space war""}, {""id"": 3388, ""name"": ""space colony""}, {""id"": 3679, ""name"": ""society""}, {""id"": 3801, ""name"": ""space travel""}, {""id"": 9685, ""name"": ""futuristic""}, {""id"": 9840, ""name"": ""romance""}, {""id"": 9882, ""name"": ""space""}, {""id"": 9951, ""name"": ""alien""}, {""id"": 10148, ""name"": ""tribe""}, {""id"": 10158, ""name"": ""alien planet""}, {""id"": 10987, ""name"": ""cgi""}, {""id"": 11399, ""name"": ""marine""}, {""id"": 13065, ""name"": ""soldier""}, {""id"": 14643, ""name"": ""battle""}, {""id"": 14720, ""name"": ""love affair""}, {""id"": 165431, ""name"": ""anti war""}, {""id"": 193554, ""name"": ""power relations""}, {""id"": 206690, ""name"": ""mind and soul""}, {""id"": 209714, ""name"": ""3d""}]",en,Avatar,"In the 22nd century, a paraplegic Marine is dispatched to the moon Pandora on a unique mission, but becomes torn between following orders and protecting an alien civilization.",150.437577,"[{""name"": ""Ingenious Film Partners"", ""id"": 289}, {""name"": ""Twentieth Century Fox Film Corporation"", ""id"": 306}, {""name"": ""Dune Entertainment"", ""id"": 444}, {""name"": ""Lightstorm Entertainment"", ""id"": 574}]","[{""iso_3166_1"": ""US"", ""name"": ""United States of America""}, {""iso_3166_1"": ""GB"", ""name"": ""United Kingdom""}]",2009-12-10,2787965087,162,"[{""iso_639_1"": ""en"", ""name"": ""English""}, {""iso_639_1"": ""es"", ""name"": ""Espa\\u00f1ol""}]",Released,Enter the World of Pandora.,Avatar,7.2,11800\n']
In [6]:
#Read as a Data Frame
import ast
import pandas as pd
import numpy as nm
import csv
import json
from collections import defaultdict
from pandas.io.json import json_normalize
CSV_File = pd.read_csv("tmdb_5000_movies.csv")
df = pd.DataFrame(CSV_File)
df[:10]
Out[6]:
budget
genres
homepage
id
keywords
original_language
original_title
overview
popularity
production_companies
production_countries
release_date
revenue
runtime
spoken_languages
status
tagline
title
vote_average
vote_count
0
237000000
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
http://www.avatarmovie.com/
19995
[{"id": 1463, "name": "culture clash"}, {"id":...
en
Avatar
In the 22nd century, a paraplegic Marine is di...
150.437577
[{"name": "Ingenious Film Partners", "id": 289...
[{"iso_3166_1": "US", "name": "United States o...
2009-12-10
2787965087
162.0
[{"iso_639_1": "en", "name": "English"}, {"iso...
Released
Enter the World of Pandora.
Avatar
7.2
11800
1
300000000
[{"id": 12, "name": "Adventure"}, {"id": 14, "...
http://disney.go.com/disneypictures/pirates/
285
[{"id": 270, "name": "ocean"}, {"id": 726, "na...
en
Pirates of the Caribbean: At World's End
Captain Barbossa, long believed to be dead, ha...
139.082615
[{"name": "Walt Disney Pictures", "id": 2}, {"...
[{"iso_3166_1": "US", "name": "United States o...
2007-05-19
961000000
169.0
[{"iso_639_1": "en", "name": "English"}]
Released
At the end of the world, the adventure begins.
Pirates of the Caribbean: At World's End
6.9
4500
2
245000000
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
http://www.sonypictures.com/movies/spectre/
206647
[{"id": 470, "name": "spy"}, {"id": 818, "name...
en
Spectre
A cryptic message from Bond’s past sends him o...
107.376788
[{"name": "Columbia Pictures", "id": 5}, {"nam...
[{"iso_3166_1": "GB", "name": "United Kingdom"...
2015-10-26
880674609
148.0
[{"iso_639_1": "fr", "name": "Fran\u00e7ais"},...
Released
A Plan No One Escapes
Spectre
6.3
4466
3
250000000
[{"id": 28, "name": "Action"}, {"id": 80, "nam...
http://www.thedarkknightrises.com/
49026
[{"id": 849, "name": "dc comics"}, {"id": 853,...
en
The Dark Knight Rises
Following the death of District Attorney Harve...
112.312950
[{"name": "Legendary Pictures", "id": 923}, {"...
[{"iso_3166_1": "US", "name": "United States o...
2012-07-16
1084939099
165.0
[{"iso_639_1": "en", "name": "English"}]
Released
The Legend Ends
The Dark Knight Rises
7.6
9106
4
260000000
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
http://movies.disney.com/john-carter
49529
[{"id": 818, "name": "based on novel"}, {"id":...
en
John Carter
John Carter is a war-weary, former military ca...
43.926995
[{"name": "Walt Disney Pictures", "id": 2}]
[{"iso_3166_1": "US", "name": "United States o...
2012-03-07
284139100
132.0
[{"iso_639_1": "en", "name": "English"}]
Released
Lost in our world, found in another.
John Carter
6.1
2124
5
258000000
[{"id": 14, "name": "Fantasy"}, {"id": 28, "na...
http://www.sonypictures.com/movies/spider-man3/
559
[{"id": 851, "name": "dual identity"}, {"id": ...
en
Spider-Man 3
The seemingly invincible Spider-Man goes up ag...
115.699814
[{"name": "Columbia Pictures", "id": 5}, {"nam...
[{"iso_3166_1": "US", "name": "United States o...
2007-05-01
890871626
139.0
[{"iso_639_1": "en", "name": "English"}, {"iso...
Released
The battle within.
Spider-Man 3
5.9
3576
6
260000000
[{"id": 16, "name": "Animation"}, {"id": 10751...
http://disney.go.com/disneypictures/tangled/
38757
[{"id": 1562, "name": "hostage"}, {"id": 2343,...
en
Tangled
When the kingdom's most wanted-and most charmi...
48.681969
[{"name": "Walt Disney Pictures", "id": 2}, {"...
[{"iso_3166_1": "US", "name": "United States o...
2010-11-24
591794936
100.0
[{"iso_639_1": "en", "name": "English"}]
Released
They're taking adventure to new lengths.
Tangled
7.4
3330
7
280000000
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
http://marvel.com/movies/movie/193/avengers_ag...
99861
[{"id": 8828, "name": "marvel comic"}, {"id": ...
en
Avengers: Age of Ultron
When Tony Stark tries to jumpstart a dormant p...
134.279229
[{"name": "Marvel Studios", "id": 420}, {"name...
[{"iso_3166_1": "US", "name": "United States o...
2015-04-22
1405403694
141.0
[{"iso_639_1": "en", "name": "English"}]
Released
A New Age Has Come.
Avengers: Age of Ultron
7.3
6767
8
250000000
[{"id": 12, "name": "Adventure"}, {"id": 14, "...
http://harrypotter.warnerbros.com/harrypottera...
767
[{"id": 616, "name": "witch"}, {"id": 2343, "n...
en
Harry Potter and the Half-Blood Prince
As Harry begins his sixth year at Hogwarts, he...
98.885637
[{"name": "Warner Bros.", "id": 6194}, {"name"...
[{"iso_3166_1": "GB", "name": "United Kingdom"...
2009-07-07
933959197
153.0
[{"iso_639_1": "en", "name": "English"}]
Released
Dark Secrets Revealed
Harry Potter and the Half-Blood Prince
7.4
5293
9
250000000
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
http://www.batmanvsupermandawnofjustice.com/
209112
[{"id": 849, "name": "dc comics"}, {"id": 7002...
en
Batman v Superman: Dawn of Justice
Fearing the actions of a god-like Super Hero l...
155.790452
[{"name": "DC Comics", "id": 429}, {"name": "A...
[{"iso_3166_1": "US", "name": "United States o...
2016-03-23
873260194
151.0
[{"iso_639_1": "en", "name": "English"}]
Released
Justice or revenge
Batman v Superman: Dawn of Justice
5.7
7004
In [7]:
CSV_File = pd.read_csv("tmdb_5000_movies.csv")
df = pd.DataFrame(CSV_File)
df[:10]
Out[7]:
budget
genres
homepage
id
keywords
original_language
original_title
overview
popularity
production_companies
production_countries
release_date
revenue
runtime
spoken_languages
status
tagline
title
vote_average
vote_count
0
237000000
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
http://www.avatarmovie.com/
19995
[{"id": 1463, "name": "culture clash"}, {"id":...
en
Avatar
In the 22nd century, a paraplegic Marine is di...
150.437577
[{"name": "Ingenious Film Partners", "id": 289...
[{"iso_3166_1": "US", "name": "United States o...
2009-12-10
2787965087
162.0
[{"iso_639_1": "en", "name": "English"}, {"iso...
Released
Enter the World of Pandora.
Avatar
7.2
11800
1
300000000
[{"id": 12, "name": "Adventure"}, {"id": 14, "...
http://disney.go.com/disneypictures/pirates/
285
[{"id": 270, "name": "ocean"}, {"id": 726, "na...
en
Pirates of the Caribbean: At World's End
Captain Barbossa, long believed to be dead, ha...
139.082615
[{"name": "Walt Disney Pictures", "id": 2}, {"...
[{"iso_3166_1": "US", "name": "United States o...
2007-05-19
961000000
169.0
[{"iso_639_1": "en", "name": "English"}]
Released
At the end of the world, the adventure begins.
Pirates of the Caribbean: At World's End
6.9
4500
2
245000000
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
http://www.sonypictures.com/movies/spectre/
206647
[{"id": 470, "name": "spy"}, {"id": 818, "name...
en
Spectre
A cryptic message from Bond’s past sends him o...
107.376788
[{"name": "Columbia Pictures", "id": 5}, {"nam...
[{"iso_3166_1": "GB", "name": "United Kingdom"...
2015-10-26
880674609
148.0
[{"iso_639_1": "fr", "name": "Fran\u00e7ais"},...
Released
A Plan No One Escapes
Spectre
6.3
4466
3
250000000
[{"id": 28, "name": "Action"}, {"id": 80, "nam...
http://www.thedarkknightrises.com/
49026
[{"id": 849, "name": "dc comics"}, {"id": 853,...
en
The Dark Knight Rises
Following the death of District Attorney Harve...
112.312950
[{"name": "Legendary Pictures", "id": 923}, {"...
[{"iso_3166_1": "US", "name": "United States o...
2012-07-16
1084939099
165.0
[{"iso_639_1": "en", "name": "English"}]
Released
The Legend Ends
The Dark Knight Rises
7.6
9106
4
260000000
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
http://movies.disney.com/john-carter
49529
[{"id": 818, "name": "based on novel"}, {"id":...
en
John Carter
John Carter is a war-weary, former military ca...
43.926995
[{"name": "Walt Disney Pictures", "id": 2}]
[{"iso_3166_1": "US", "name": "United States o...
2012-03-07
284139100
132.0
[{"iso_639_1": "en", "name": "English"}]
Released
Lost in our world, found in another.
John Carter
6.1
2124
5
258000000
[{"id": 14, "name": "Fantasy"}, {"id": 28, "na...
http://www.sonypictures.com/movies/spider-man3/
559
[{"id": 851, "name": "dual identity"}, {"id": ...
en
Spider-Man 3
The seemingly invincible Spider-Man goes up ag...
115.699814
[{"name": "Columbia Pictures", "id": 5}, {"nam...
[{"iso_3166_1": "US", "name": "United States o...
2007-05-01
890871626
139.0
[{"iso_639_1": "en", "name": "English"}, {"iso...
Released
The battle within.
Spider-Man 3
5.9
3576
6
260000000
[{"id": 16, "name": "Animation"}, {"id": 10751...
http://disney.go.com/disneypictures/tangled/
38757
[{"id": 1562, "name": "hostage"}, {"id": 2343,...
en
Tangled
When the kingdom's most wanted-and most charmi...
48.681969
[{"name": "Walt Disney Pictures", "id": 2}, {"...
[{"iso_3166_1": "US", "name": "United States o...
2010-11-24
591794936
100.0
[{"iso_639_1": "en", "name": "English"}]
Released
They're taking adventure to new lengths.
Tangled
7.4
3330
7
280000000
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
http://marvel.com/movies/movie/193/avengers_ag...
99861
[{"id": 8828, "name": "marvel comic"}, {"id": ...
en
Avengers: Age of Ultron
When Tony Stark tries to jumpstart a dormant p...
134.279229
[{"name": "Marvel Studios", "id": 420}, {"name...
[{"iso_3166_1": "US", "name": "United States o...
2015-04-22
1405403694
141.0
[{"iso_639_1": "en", "name": "English"}]
Released
A New Age Has Come.
Avengers: Age of Ultron
7.3
6767
8
250000000
[{"id": 12, "name": "Adventure"}, {"id": 14, "...
http://harrypotter.warnerbros.com/harrypottera...
767
[{"id": 616, "name": "witch"}, {"id": 2343, "n...
en
Harry Potter and the Half-Blood Prince
As Harry begins his sixth year at Hogwarts, he...
98.885637
[{"name": "Warner Bros.", "id": 6194}, {"name"...
[{"iso_3166_1": "GB", "name": "United Kingdom"...
2009-07-07
933959197
153.0
[{"iso_639_1": "en", "name": "English"}]
Released
Dark Secrets Revealed
Harry Potter and the Half-Blood Prince
7.4
5293
9
250000000
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
http://www.batmanvsupermandawnofjustice.com/
209112
[{"id": 849, "name": "dc comics"}, {"id": 7002...
en
Batman v Superman: Dawn of Justice
Fearing the actions of a god-like Super Hero l...
155.790452
[{"name": "DC Comics", "id": 429}, {"name": "A...
[{"iso_3166_1": "US", "name": "United States o...
2016-03-23
873260194
151.0
[{"iso_639_1": "en", "name": "English"}]
Released
Justice or revenge
Batman v Superman: Dawn of Justice
5.7
7004
In [8]:
df_n = pd.DataFrame(df["genres"])
#df_n[:20]
In [9]:
multi_columns = ['genres']
for column in multi_columns:
df[column] = df[column].apply(json.loads)
df_new = pd.DataFrame(df[column].astype(str) )
stack = df[column].astype(str)
#print (stack)
df_new[:10]
Out[9]:
genres
0
[{'id': 28, 'name': 'Action'}, {'id': 12, 'nam...
1
[{'id': 12, 'name': 'Adventure'}, {'id': 14, '...
2
[{'id': 28, 'name': 'Action'}, {'id': 12, 'nam...
3
[{'id': 28, 'name': 'Action'}, {'id': 80, 'nam...
4
[{'id': 28, 'name': 'Action'}, {'id': 12, 'nam...
5
[{'id': 14, 'name': 'Fantasy'}, {'id': 28, 'na...
6
[{'id': 16, 'name': 'Animation'}, {'id': 10751...
7
[{'id': 28, 'name': 'Action'}, {'id': 12, 'nam...
8
[{'id': 12, 'name': 'Adventure'}, {'id': 14, '...
9
[{'id': 28, 'name': 'Action'}, {'id': 12, 'nam...
In [12]:
CSV_File = pd.read_csv("tmdb_5000_movies.csv")
df = pd.DataFrame(CSV_File)
#df
def list_of_dicts(ld):
return dict([(list(d.values())[1], list(d.values())[0]) for d in ast.literal_eval(ld)])
def list_of_dicts(ld):
return dict([(list(d.values())[1], '1') for d in ast.literal_eval(ld)])
In [13]:
dt = df['genres']
g = dt.apply(list_of_dicts).tolist()
g[:10]
Out[13]:
[{'Action': '1', 'Adventure': '1', 'Fantasy': '1', 'Science Fiction': '1'},
{'Action': '1', 'Adventure': '1', 'Fantasy': '1'},
{'Action': '1', 'Adventure': '1', 'Crime': '1'},
{'Action': '1', 'Crime': '1', 'Drama': '1', 'Thriller': '1'},
{'Action': '1', 'Adventure': '1', 'Science Fiction': '1'},
{'Action': '1', 'Adventure': '1', 'Fantasy': '1'},
{'Animation': '1', 'Family': '1'},
{'Action': '1', 'Adventure': '1', 'Science Fiction': '1'},
{'Adventure': '1', 'Family': '1', 'Fantasy': '1'},
{'Action': '1', 'Adventure': '1', 'Fantasy': '1'}]
In [24]:
import numpy as np
l = df['genres']
a = np.array(l, dtype=pd.Series)
a
Out[24]:
array([ '[{"id": 28, "name": "Action"}, {"id": 12, "name": "Adventure"}, {"id": 14, "name": "Fantasy"}, {"id": 878, "name": "Science Fiction"}]',
'[{"id": 12, "name": "Adventure"}, {"id": 14, "name": "Fantasy"}, {"id": 28, "name": "Action"}]',
'[{"id": 28, "name": "Action"}, {"id": 12, "name": "Adventure"}, {"id": 80, "name": "Crime"}]',
...,
'[{"id": 35, "name": "Comedy"}, {"id": 18, "name": "Drama"}, {"id": 10749, "name": "Romance"}, {"id": 10770, "name": "TV Movie"}]',
'[]', '[{"id": 99, "name": "Documentary"}]'], dtype=object)
In [25]:
Gen = json_normalize(df['genres'].apply(list_of_dicts).tolist()).add_prefix('')
Gen = Gen.drop_duplicates()
a = np.array(Gen, dtype=pd.Series)
df_Gen_wide = Gen.join(df)
df_Gen_wide = df_Gen_wide.fillna(0)
df_Gen_wide[:10]
Out[25]:
Action
Adventure
Animation
Comedy
Crime
Documentary
Drama
Family
Fantasy
Foreign
...
production_countries
release_date
revenue
runtime
spoken_languages
status
tagline
title
vote_average
vote_count
0
1
1
0
0
0
0
0
0
1
0
...
[{"iso_3166_1": "US", "name": "United States o...
2009-12-10
2787965087
162.0
[{"iso_639_1": "en", "name": "English"}, {"iso...
Released
Enter the World of Pandora.
Avatar
7.2
11800
1
1
1
0
0
0
0
0
0
1
0
...
[{"iso_3166_1": "US", "name": "United States o...
2007-05-19
961000000
169.0
[{"iso_639_1": "en", "name": "English"}]
Released
At the end of the world, the adventure begins.
Pirates of the Caribbean: At World's End
6.9
4500
2
1
1
0
0
1
0
0
0
0
0
...
[{"iso_3166_1": "GB", "name": "United Kingdom"...
2015-10-26
880674609
148.0
[{"iso_639_1": "fr", "name": "Fran\u00e7ais"},...
Released
A Plan No One Escapes
Spectre
6.3
4466
3
1
0
0
0
1
0
1
0
0
0
...
[{"iso_3166_1": "US", "name": "United States o...
2012-07-16
1084939099
165.0
[{"iso_639_1": "en", "name": "English"}]
Released
The Legend Ends
The Dark Knight Rises
7.6
9106
4
1
1
0
0
0
0
0
0
0
0
...
[{"iso_3166_1": "US", "name": "United States o...
2012-03-07
284139100
132.0
[{"iso_639_1": "en", "name": "English"}]
Released
Lost in our world, found in another.
John Carter
6.1
2124
6
0
0
1
0
0
0
0
1
0
0
...
[{"iso_3166_1": "US", "name": "United States o...
2010-11-24
591794936
100.0
[{"iso_639_1": "en", "name": "English"}]
Released
They're taking adventure to new lengths.
Tangled
7.4
3330
8
0
1
0
0
0
0
0
1
1
0
...
[{"iso_3166_1": "GB", "name": "United Kingdom"...
2009-07-07
933959197
153.0
[{"iso_639_1": "en", "name": "English"}]
Released
Dark Secrets Revealed
Harry Potter and the Half-Blood Prince
7.4
5293
11
1
1
0
0
1
0
0
0
0
0
...
[{"iso_3166_1": "GB", "name": "United Kingdom"...
2008-10-30
586090727
106.0
[{"iso_639_1": "en", "name": "English"}, {"iso...
Released
For love, for hate, for justice, for revenge.
Quantum of Solace
6.1
2965
13
1
1
0
0
0
0
0
0
0
0
...
[{"iso_3166_1": "US", "name": "United States o...
2013-07-03
89289910
149.0
[{"iso_639_1": "en", "name": "English"}]
Released
Never Take Off the Mask
The Lone Ranger
5.9
2311
18
1
0
0
1
0
0
0
0
0
0
...
[{"iso_3166_1": "US", "name": "United States o...
2012-05-23
624026776
106.0
[{"iso_639_1": "en", "name": "English"}]
Released
They are back... in time.
Men in Black 3
6.2
4160
10 rows × 40 columns
In [27]:
GenT = Gen.T
GenT = GenT.drop_duplicates()
In [28]:
dfT = df.T
In [29]:
df_long = dfT.append([GenT])
df_long = df_long.fillna(0)
df_long[:100]
Out[29]:
0
1
2
3
4
5
6
7
8
9
...
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
budget
237000000
300000000
245000000
250000000
260000000
258000000
260000000
280000000
250000000
250000000
...
0
0
0
7000
0
220000
9000
0
0
0
genres
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
[{"id": 12, "name": "Adventure"}, {"id": 14, "...
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
[{"id": 28, "name": "Action"}, {"id": 80, "nam...
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
[{"id": 14, "name": "Fantasy"}, {"id": 28, "na...
[{"id": 16, "name": "Animation"}, {"id": 10751...
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
[{"id": 12, "name": "Adventure"}, {"id": 14, "...
[{"id": 28, "name": "Action"}, {"id": 12, "nam...
...
[{"id": 18, "name": "Drama"}]
[{"id": 53, "name": "Thriller"}, {"id": 27, "n...
[{"id": 18, "name": "Drama"}]
[{"id": 878, "name": "Science Fiction"}, {"id"...
[{"id": 10769, "name": "Foreign"}, {"id": 53, ...
[{"id": 28, "name": "Action"}, {"id": 80, "nam...
[{"id": 35, "name": "Comedy"}, {"id": 10749, "...
[{"id": 35, "name": "Comedy"}, {"id": 18, "nam...
[]
[{"id": 99, "name": "Documentary"}]
homepage
http://www.avatarmovie.com/
http://disney.go.com/disneypictures/pirates/
http://www.sonypictures.com/movies/spectre/
http://www.thedarkknightrises.com/
http://movies.disney.com/john-carter
http://www.sonypictures.com/movies/spider-man3/
http://disney.go.com/disneypictures/tangled/
http://marvel.com/movies/movie/193/avengers_ag...
http://harrypotter.warnerbros.com/harrypottera...
http://www.batmanvsupermandawnofjustice.com/
...
0
0
0
http://www.primermovie.com
0
0
0
http://www.hallmarkchannel.com/signedsealeddel...
http://shanghaicalling.com/
0
id
19995
285
206647
49026
49529
559
38757
99861
767
209112
...
182291
286939
124606
14337
67238
9367
72766
231617
126186
25975
keywords
[{"id": 1463, "name": "culture clash"}, {"id":...
[{"id": 270, "name": "ocean"}, {"id": 726, "na...
[{"id": 470, "name": "spy"}, {"id": 818, "name...
[{"id": 849, "name": "dc comics"}, {"id": 853,...
[{"id": 818, "name": "based on novel"}, {"id":...
[{"id": 851, "name": "dual identity"}, {"id": ...
[{"id": 1562, "name": "hostage"}, {"id": 2343,...
[{"id": 8828, "name": "marvel comic"}, {"id": ...
[{"id": 616, "name": "witch"}, {"id": 2343, "n...
[{"id": 849, "name": "dc comics"}, {"id": 7002...
...
[{"id": 718, "name": "confession"}, {"id": 100...
[]
[{"id": 10726, "name": "gang"}, {"id": 33928, ...
[{"id": 1448, "name": "distrust"}, {"id": 2101...
[]
[{"id": 5616, "name": "united states\u2013mexi...
[]
[{"id": 248, "name": "date"}, {"id": 699, "nam...
[]
[{"id": 1523, "name": "obsession"}, {"id": 224...
original_language
en
en
en
en
en
en
en
en
en
en
...
en
en
en
en
en
es
en
en
en
en
original_title
Avatar
Pirates of the Caribbean: At World's End
Spectre
The Dark Knight Rises
John Carter
Spider-Man 3
Tangled
Avengers: Age of Ultron
Harry Potter and the Half-Blood Prince
Batman v Superman: Dawn of Justice
...
On The Downlow
Sanctuary: Quite a Conundrum
Bang
Primer
Cavite
El Mariachi
Newlyweds
Signed, Sealed, Delivered
Shanghai Calling
My Date with Drew
overview
In the 22nd century, a paraplegic Marine is di...
Captain Barbossa, long believed to be dead, ha...
A cryptic message from Bond’s past sends him o...
Following the death of District Attorney Harve...
John Carter is a war-weary, former military ca...
The seemingly invincible Spider-Man goes up ag...
When the kingdom's most wanted-and most charmi...
When Tony Stark tries to jumpstart a dormant p...
As Harry begins his sixth year at Hogwarts, he...
Fearing the actions of a god-like Super Hero l...
...
Isaac and Angel are two young Latinos involved...
It should have been just a normal day of sex, ...
A young woman in L.A. is having a bad day: she...
Friends/fledgling entrepreneurs invent a devic...
Adam, a security guard, travels from Californi...
El Mariachi just wants to play his guitar and ...
A newlywed couple's honeymoon is upended by th...
"Signed, Sealed, Delivered" introduces a dedic...
When ambitious New York attorney Sam is sent t...
Ever since the second grade when he first saw ...
popularity
150.438
139.083
107.377
112.313
43.927
115.7
48.682
134.279
98.8856
155.79
...
0.029757
0.166513
0.918116
23.3079
0.022173
14.2698
0.642552
1.44448
0.857008
1.92988
production_companies
[{"name": "Ingenious Film Partners", "id": 289...
[{"name": "Walt Disney Pictures", "id": 2}, {"...
[{"name": "Columbia Pictures", "id": 5}, {"nam...
[{"name": "Legendary Pictures", "id": 923}, {"...
[{"name": "Walt Disney Pictures", "id": 2}]
[{"name": "Columbia Pictures", "id": 5}, {"nam...
[{"name": "Walt Disney Pictures", "id": 2}, {"...
[{"name": "Marvel Studios", "id": 420}, {"name...
[{"name": "Warner Bros.", "id": 6194}, {"name"...
[{"name": "DC Comics", "id": 429}, {"name": "A...
...
[{"name": "Iconoclast Films", "id": 26677}]
[{"name": "Gold Lion Films", "id": 37870}, {"n...
[{"name": "Asylum Films", "id": 10571}, {"name...
[{"name": "Thinkfilm", "id": 446}]
[]
[{"name": "Columbia Pictures", "id": 5}]
[]
[{"name": "Front Street Pictures", "id": 3958}...
[]
[{"name": "rusty bear entertainment", "id": 87...
production_countries
[{"iso_3166_1": "US", "name": "United States o...
[{"iso_3166_1": "US", "name": "United States o...
[{"iso_3166_1": "GB", "name": "United Kingdom"...
[{"iso_3166_1": "US", "name": "United States o...
[{"iso_3166_1": "US", "name": "United States o...
[{"iso_3166_1": "US", "name": "United States o...
[{"iso_3166_1": "US", "name": "United States o...
[{"iso_3166_1": "US", "name": "United States o...
[{"iso_3166_1": "GB", "name": "United Kingdom"...
[{"iso_3166_1": "US", "name": "United States o...
...
[{"iso_3166_1": "US", "name": "United States o...
[{"iso_3166_1": "US", "name": "United States o...
[{"iso_3166_1": "US", "name": "United States o...
[{"iso_3166_1": "US", "name": "United States o...
[]
[{"iso_3166_1": "MX", "name": "Mexico"}, {"iso...
[]
[{"iso_3166_1": "US", "name": "United States o...
[{"iso_3166_1": "US", "name": "United States o...
[{"iso_3166_1": "US", "name": "United States o...
release_date
2009-12-10
2007-05-19
2015-10-26
2012-07-16
2012-03-07
2007-05-01
2010-11-24
2015-04-22
2009-07-07
2016-03-23
...
2004-04-11
2012-01-20
1995-09-09
2004-10-08
2005-03-12
1992-09-04
2011-12-26
2013-10-13
2012-05-03
2005-08-05
revenue
2787965087
961000000
880674609
1084939099
284139100
890871626
591794936
1405403694
933959197
873260194
...
0
0
0
424760
0
2040920
0
0
0
0
runtime
162
169
148
165
132
139
100
141
153
151
...
90
82
98
77
80
81
85
120
98
90
spoken_languages
[{"iso_639_1": "en", "name": "English"}, {"iso...
[{"iso_639_1": "en", "name": "English"}]
[{"iso_639_1": "fr", "name": "Fran\u00e7ais"},...
[{"iso_639_1": "en", "name": "English"}]
[{"iso_639_1": "en", "name": "English"}]
[{"iso_639_1": "en", "name": "English"}, {"iso...
[{"iso_639_1": "en", "name": "English"}]
[{"iso_639_1": "en", "name": "English"}]
[{"iso_639_1": "en", "name": "English"}]
[{"iso_639_1": "en", "name": "English"}]
...
[]
[{"iso_639_1": "en", "name": "English"}]
[{"iso_639_1": "en", "name": "English"}]
[{"iso_639_1": "en", "name": "English"}]
[]
[{"iso_639_1": "es", "name": "Espa\u00f1ol"}]
[]
[{"iso_639_1": "en", "name": "English"}]
[{"iso_639_1": "en", "name": "English"}]
[{"iso_639_1": "en", "name": "English"}]
status
Released
Released
Released
Released
Released
Released
Released
Released
Released
Released
...
Released
Released
Released
Released
Released
Released
Released
Released
Released
Released
tagline
Enter the World of Pandora.
At the end of the world, the adventure begins.
A Plan No One Escapes
The Legend Ends
Lost in our world, found in another.
The battle within.
They're taking adventure to new lengths.
A New Age Has Come.
Dark Secrets Revealed
Justice or revenge
...
Two gangs. One secret. One crossroad.
0
Sometimes you've got to break the rules
What happens if it actually works?
0
He didn't come looking for trouble, but troubl...
A newlywed couple's honeymoon is upended by th...
0
A New Yorker in Shanghai
0
title
Avatar
Pirates of the Caribbean: At World's End
Spectre
The Dark Knight Rises
John Carter
Spider-Man 3
Tangled
Avengers: Age of Ultron
Harry Potter and the Half-Blood Prince
Batman v Superman: Dawn of Justice
...
On The Downlow
Sanctuary: Quite a Conundrum
Bang
Primer
Cavite
El Mariachi
Newlyweds
Signed, Sealed, Delivered
Shanghai Calling
My Date with Drew
vote_average
7.2
6.9
6.3
7.6
6.1
5.9
7.4
7.3
7.4
5.7
...
6
0
6
6.9
7.5
6.6
5.9
7
5.7
6.3
vote_count
11800
4500
4466
9106
2124
3576
3330
6767
5293
7004
...
2
0
1
658
2
238
5
6
7
16
Action
1
1
1
1
1
0
0
0
0
0
...
0
0
0
0
0
0
0
0
0
0
Adventure
1
1
1
0
1
0
0
0
1
0
...
0
0
0
0
0
0
0
0
0
0
Animation
0
0
0
0
0
0
1
0
0
0
...
0
0
0
0
0
0
0
0
0
0
Comedy
0
0
0
0
0
0
0
0
0
0
...
0
0
0
0
0
0
0
1
0
0
Crime
0
0
1
1
0
0
0
0
0
0
...
0
0
0
0
0
0
0
0
0
0
Documentary
0
0
0
0
0
0
0
0
0
0
...
0
0
0
0
0
0
0
0
0
0
Drama
0
0
0
1
0
0
0
0
0
0
...
0
0
0
0
0
0
0
1
0
0
Family
0
0
0
0
0
0
1
0
1
0
...
0
0
0
0
0
0
0
0
0
0
Fantasy
1
1
0
0
0
0
0
0
1
0
...
0
0
0
0
0
0
0
0
0
0
Foreign
0
0
0
0
0
0
0
0
0
0
...
0
0
0
0
1
0
0
0
0
0
History
0
0
0
0
0
0
0
0
0
0
...
0
0
0
0
0
0
0
0
0
0
Horror
0
0
0
0
0
0
0
0
0
0
...
0
0
0
0
0
0
0
0
0
0
Music
0
0
0
0
0
0
0
0
0
0
...
0
0
0
0
0
0
0
0
0
0
Mystery
0
0
0
0
0
0
0
0
0
0
...
0
0
0
0
0
0
0
0
0
0
Romance
0
0
0
0
0
0
0
0
0
0
...
0
0
0
0
0
0
0
1
0
0
Science Fiction
1
0
0
0
1
0
0
0
0
0
...
0
0
0
0
0
0
0
0
0
0
TV Movie
0
0
0
0
0
0
0
0
0
0
...
0
0
0
0
0
0
0
1
0
0
Thriller
0
0
0
1
0
0
0
0
0
0
...
0
0
0
0
1
0
0
0
0
0
War
0
0
0
0
0
0
0
0
0
0
...
0
0
0
0
0
0
0
0
0
0
Western
0
0
0
0
0
0
0
0
0
0
...
0
0
0
0
0
0
0
0
0
0
40 rows × 4803 columns
In [ ]:
Does lond data expansion result in data duplication? - Yes
Content source: Fifth-Cohort-Awesome/NightThree
Similar notebooks: