In [1]:
%matplotlib inline
from collections import Counter

import pandas as pd

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


Out[2]:

In [3]:
video_games = pd.read_json("videogames.json")
video_games.head(5)


Out[3]:
brand categories description imUrl price productID related salesRank title
1012282 Dark Age Miniatures [[Video Games, PC, Games]] None http://ecx.images-amazon.com/images/I/61IaJuP1... 31.23 0984529527 None {u'Toys & Games': 751946} Dark Age Apocalypse: Forcelists HC
1315355 None [[Video Games, PC, Games]] Microsoft's Flight Simulator X is now making i... http://ecx.images-amazon.com/images/I/41TaIYT%... 27.64 1557556741 {u'also_bought': [u'B002JZH9E4'], u'buy_after_... {u'Video Games': 61369} None
1321069 None [[Video Games, PC, Games]] CYBERPUNK VAMPIRE ROLE-PLAYING PC GAME SET IN ... http://ecx.images-amazon.com/images/I/41HClAKt... NaN 1558843477 None {u'Video Games': 56174} None
1336988 None [[Video Games, PC, Games]] None http://ecx.images-amazon.com/images/I/41PBCXQ3... 43.99 1563820412 None {u'Software': 47380} None
1377319 Palladium Books [[Video Games, Nintendo DS, Games]] The Rifter is your doorway to unlimited imagin... http://ecx.images-amazon.com/images/I/41r7cYfc... 9.55 1574571931 {u'also_bought': [u'157457194X', u'1574571923'... {u'Toys & Games': 594770} Rifts RPG: The Rifter&reg; #56

How many video games are there?


In [4]:
len(video_games)


Out[4]:
50210

Which 5 brand have more video games?


In [5]:
video_games["brand"].value_counts().nlargest(5)


Out[5]:
Generic        40
Mad Catz       35
Logitech       35
SteelSeries    32
Razer          25
Name: brand, dtype: int64

Is there a video game that has no title? If there is, count of untitled video games


In [6]:
len(video_games[video_games.title.isnull()])


Out[6]:
48071

Remove video games which has no title?


In [7]:
video_games = video_games[~video_games.title.isnull()]

In [8]:
video_games = video_games.dropna(subset=["title"])

How many categories are there in video_games dataframe?


In [9]:
list_of_category_lists = video_games.categories.sum()
len(set(x for l in list_of_category_lists for x in l))


Out[9]:
126

Find the number of video games by per category


In [10]:
counter = Counter()
video_games.categories.apply(lambda x: Counter(x[0])).sum().most_common(5)


Out[10]:
[(u'Video Games', 2099),
 (u'Accessories', 1778),
 (u'PC', 874),
 (u'Controllers', 453),
 (u'More Systems', 284)]

Which is the most expensive video game?


In [11]:
video_games.loc[video_games['price'].idxmax()]


Out[11]:
brand                                                       None
categories     [[Video Games, PC, Accessories, Controllers, S...
description    Amazing Racing Wheel, and Pedals Combination f...
imUrl          http://ecx.images-amazon.com/images/I/41T3IjzI...
price                                                     759.12
productID                                             B00006JJIC
related        {u'also_viewed': [u'B001NT9TK4', u'B000ODVKUC'...
salesRank                                                     {}
title          Logitech MOMO Racing - Wheel and pedals set - ...
Name: 2123933, dtype: object

Which is the cheapest video game?


In [12]:
video_games.loc[video_games['price'].idxmin()]


Out[12]:
brand                                                       None
categories     [[Video Games, More Systems, PlayStation 2, Ha...
description    Now you can play your favorite movies without ...
imUrl          http://ecx.images-amazon.com/images/I/319XlHJ0...
price                                                       0.01
productID                                             B00006JPQV
related        {u'also_viewed': [u'B00009W5WH', u'B002EB6XGS'...
salesRank                                                   None
title          MADCATZ 8241 DVD 2 Wireless Remote for PlaySta...
Name: 2125183, dtype: object

Find all games which has "Age Of" in titles (case insensitive way)


In [13]:
video_games[video_games['title'].str.lower().str.contains("age of")]


Out[13]:
brand categories description imUrl price productID related salesRank title
2225346 None [[Video Games, More Systems, PDAs]] None http://ecx.images-amazon.com/images/I/517GX364... 41.99 B0001594QK {u'also_viewed': [u'B000J18SR2'], u'buy_after_... {u'Electronics': 221730} Age Of Empires: Pocket PC Edition
3466444 None [[Video Games, More Systems, PlayStation 2, Ha... From the ManufacturerAge of Conan brings you i... http://ecx.images-amazon.com/images/I/41ZYNx63... 9.20 B001697TB2 {u'also_viewed': [u'B0075W8DG4', u'B00FWK8UWI'... None Ideazon Age of Conan Keyset for Zboard
4876866 Strategy First [[Video Games, PC, Games]] Platform:&nbsp;&nbsp;WINDOWS XP/VISTA/WINDOWS ... http://ecx.images-amazon.com/images/I/41Fim6ES... 4.00 B003VEFXTU None None Galactic Dream - Rage Of War

Calculate the averate price


In [14]:
video_games["price"].mean()


Out[14]:
40.179939226519338

All prices are given in dollar and convert it to euro ( let's say 1 dollar is 0.85 euro)


In [15]:
video_games["price_in_euro"] = video_games["price"] * 0.85
video_games["price_in_euro"].head()


Out[15]:
1012282    26.5455
1377319     8.1175
1458323        NaN
1528242    13.1580
1536208    28.8660
Name: price_in_euro, dtype: float64

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: