In [1]:
import pandas as pd
import numpy as np
import statsmodels.api as sm
import matplotlib.pyplot as plt
from pandas.stats.api import ols
import warnings
warnings.filterwarnings('ignore')
data = pd.read_json("OverwatchFullDB.json")
In [3]:
rank = [x for x in data['rank']]
level = [x for x in data['level']]
comp = [x for x in data.get('comp', {})]
qp = [x for x in data.get('qp', {})]
heroes = [x for x in data.get('heroes', {})]
In [4]:
def getAvgElims(x):
b = x.get('average', {})
return(b.get('elims', {}))
def getTotalElims(x):
b = x.get('total', {})
return(b.get('elims', {}))
def getMostElims(x):
b = x.get('most', {})
return(b.get('elims', {}))
def getGames(x):
b = x.get('total',{})
return(b.get('games',{}))
def getAna(x):
b = x.get('playtime',{})
return(b.get('ana',{}))
def getBastion(x):
b = x.get('playtime',{})
return(b.get('bastion',{}))
def getDva(x):
b = x.get('playtime',{})
return(b.get('dva',{}))
def getGenji(x):
b = x.get('playtime',{})
return(b.get('genji',{}))
def getHanzo(x):
b = x.get('playtime',{})
return(b.get('hanzo',{}))
def getJunkrat(x):
b = x.get('playtime',{})
return(b.get('junkrat',{}))
def getLucio(x):
b = x.get('playtime',{})
return(b.get('lucio',{}))
def getMccree(x):
b = x.get('playtime',{})
return(b.get('mccree',{}))
def getMei(x):
b = x.get('playtime',{})
return(b.get('mei',{}))
def getMercy(x):
b = x.get('playtime',{})
return(b.get('mercy',{}))
def getOrisa(x):
b = x.get('playtime',{})
return(b.get('orisa',{}))
def getPharah(x):
b = x.get('playtime',{})
return(b.get('pharah',{}))
def getReaper(x):
b = x.get('playtime',{})
return(b.get('reaper',{}))
def getReinhardt(x):
b = x.get('playtime',{})
return(b.get('reinhardt',{}))
def getRoadhog(x):
b = x.get('playtime',{})
return(b.get('roadhog',{}))
def getSoldier76(x):
b = x.get('playtime',{})
return(b.get('soldier76',{}))
def getSombra(x):
b = x.get('playtime',{})
return(b.get('sombra',{}))
def getSymmetra(x):
b = x.get('playtime',{})
return(b.get('symmetra',{}))
def getTorbjorn(x):
b = x.get('playtime',{})
return(b.get('torbjorn',{}))
def getTracer(x):
b = x.get('playtime',{})
return(b.get('tracer',{}))
def getWidowmaker(x):
b = x.get('playtime',{})
return(b.get('widowmaker',{}))
def getWinston(x):
b = x.get('playtime',{})
return(b.get('winston',{}))
def getZarya(x):
b = x.get('playtime',{})
return(b.get('zarya',{}))
def getZenyatta(x):
b = x.get('playtime',{})
return(b.get('zenyatta',{}))
def filterNaN(x):
if x<1e100:
return(x)
else:
return(0)
def filterLowRank(x):
if x > 0 and x < 1666:
return(x)
else:
return(0)
def filterMedRank(x):
if x > 1666 and x < 3332:
return(x)
else:
return(0)
def filterHighRank(x):
if x > 3332 and x < 5001:
return(x)
else:
return(0)
In [5]:
compGames = [getGames(x) for x in comp]
qpGames = [getGames(x) for x in qp]
anaHours = [getAna(x) for x in heroes]
bastionHours = [getBastion(x) for x in heroes]
dvaHours = [getDva(x) for x in heroes]
genjiHours = [getGenji(x) for x in heroes]
hanzoHours = [getHanzo(x) for x in heroes]
junkratHours = [getJunkrat(x) for x in heroes]
lucioHours = [getLucio(x) for x in heroes]
mccreeHours = [getMccree(x) for x in heroes]
meiHours = [getMei(x) for x in heroes]
mercyHours = [getMercy(x) for x in heroes]
orisaHours = [getOrisa(x) for x in heroes]
pharahHours = [getPharah(x) for x in heroes]
reaperHours = [getReaper(x) for x in heroes]
reinhardtHours = [getReinhardt(x) for x in heroes]
roadhogHours = [getRoadhog(x) for x in heroes]
soldier76Hours = [getSoldier76(x) for x in heroes]
#sombraHours = [getSombra(x) for x in heroes]
symmetraHours = [getSymmetra(x) for x in heroes]
torbjornHours = [getTorbjorn(x) for x in heroes]
tracerHours = [getTracer(x) for x in heroes]
widowmakerHours = [getWidowmaker(x) for x in heroes]
winstonHours = [getWinston(x) for x in heroes]
zaryaHours = [getZarya(x) for x in heroes]
zenyattaHours = [getZenyatta(x) for x in heroes]
rankFiltered=[filterNaN(x) for x in rank]
levelFiltered= [filterNaN(x) for x in level]
lowRank = [filterLowRank(x) for x in rank]
medRank = [filterMedRank(x) for x in rank]
highRank = [filterHighRank(x) for x in rank]
avgElims = [getAvgElims(x) for x in comp]
totalElims = [getTotalElims(x) for x in comp]
mostElims = [getMostElims(x) for x in comp]
In [6]:
df = pd.DataFrame({"Rank": rankFiltered, "Level": level, "Comp Games": compGames, "Quick Games": qpGames, "Ana": anaHours, "Bastion": bastionHours, "D.Va": dvaHours, "Genji": genjiHours, "Hanzo": hanzoHours, "Junkrat": junkratHours, "Lucio": lucioHours, "McCree": mccreeHours, "Mei": meiHours, "Mercy": mercyHours, "Orisa": orisaHours, "Pharah": pharahHours, "Reaper": reaperHours, "Reinhardt": reinhardtHours, "Roadhog": roadhogHours, "Soldier76": soldier76Hours, "Symmetra": symmetraHours, "Torbjorn": torbjornHours, "Tracer": tracerHours, "Widowmaker": widowmakerHours, "Winston": winstonHours, "Zarya": zaryaHours, "Zenyatta": zenyattaHours})
res = ols(y = df['Rank'], x = df[['Level','Comp Games', 'Quick Games', 'Ana', 'Bastion', 'D.Va', 'Genji', 'Hanzo', 'Junkrat', 'Lucio', 'McCree', 'Mei', 'Mercy', 'Orisa', 'Pharah', 'Reaper', 'Reinhardt', 'Roadhog', 'Soldier76', 'Symmetra', 'Torbjorn', 'Tracer', 'Widowmaker', 'Winston', 'Zarya', 'Zenyatta']])
res
Out[6]:
In [7]:
df = pd.DataFrame({"Rank": rankFiltered, "Comp Games": compGames, "Ana": anaHours, "Bastion": bastionHours, "D.Va": dvaHours, "Genji": genjiHours, "Hanzo": hanzoHours, "Junkrat": junkratHours, "Lucio": lucioHours, "McCree": mccreeHours, "Mei": meiHours, "Mercy": mercyHours, "Pharah": pharahHours, "Reaper": reaperHours, "Reinhardt": reinhardtHours, "Roadhog": roadhogHours, "Soldier76": soldier76Hours, "Symmetra": symmetraHours, "Torbjorn": torbjornHours, "Tracer": tracerHours, "Widowmaker": widowmakerHours, "Winston": winstonHours, "Zarya": zaryaHours, "Zenyatta": zenyattaHours})
res = ols(y = df['Rank'], x = df[['Comp Games', 'Ana', 'Bastion', 'D.Va', 'Genji', 'Hanzo', 'Junkrat', 'Lucio', 'McCree', 'Mei', 'Mercy', 'Pharah', 'Reaper', 'Reinhardt', 'Roadhog', 'Soldier76', 'Symmetra', 'Torbjorn', 'Tracer', 'Widowmaker', 'Winston', 'Zarya', 'Zenyatta']])
res
Out[7]:
In [8]:
df = pd.DataFrame({"Rank": lowRank, "Comp Games": compGames, "Ana": anaHours, "Bastion": bastionHours, "D.Va": dvaHours, "Genji": genjiHours, "Hanzo": hanzoHours, "Junkrat": junkratHours, "Lucio": lucioHours, "McCree": mccreeHours, "Mei": meiHours, "Mercy": mercyHours, "Pharah": pharahHours, "Reaper": reaperHours, "Reinhardt": reinhardtHours, "Roadhog": roadhogHours, "Soldier76": soldier76Hours, "Symmetra": symmetraHours, "Torbjorn": torbjornHours, "Tracer": tracerHours, "Widowmaker": widowmakerHours, "Winston": winstonHours, "Zarya": zaryaHours, "Zenyatta": zenyattaHours})
res = ols(y = df['Rank'], x = df[['Comp Games', 'Ana', 'Bastion', 'D.Va', 'Genji', 'Hanzo', 'Junkrat', 'Lucio', 'McCree', 'Mei', 'Mercy', 'Pharah', 'Reaper', 'Reinhardt', 'Roadhog', 'Soldier76', 'Symmetra', 'Torbjorn', 'Tracer', 'Widowmaker', 'Winston', 'Zarya', 'Zenyatta']])
res
Out[8]:
In [9]:
df = pd.DataFrame({"Rank": medRank, "Comp Games": compGames, "Ana": anaHours, "Bastion": bastionHours, "D.Va": dvaHours, "Genji": genjiHours, "Hanzo": hanzoHours, "Junkrat": junkratHours, "Lucio": lucioHours, "McCree": mccreeHours, "Mei": meiHours, "Mercy": mercyHours, "Pharah": pharahHours, "Reaper": reaperHours, "Reinhardt": reinhardtHours, "Roadhog": roadhogHours, "Soldier76": soldier76Hours, "Symmetra": symmetraHours, "Torbjorn": torbjornHours, "Tracer": tracerHours, "Widowmaker": widowmakerHours, "Winston": winstonHours, "Zarya": zaryaHours, "Zenyatta": zenyattaHours})
res = ols(y = df['Rank'], x = df[['Comp Games', 'Ana', 'Bastion', 'D.Va', 'Genji', 'Hanzo', 'Junkrat', 'Lucio', 'McCree', 'Mei', 'Mercy', 'Pharah', 'Reaper', 'Reinhardt', 'Roadhog', 'Soldier76', 'Symmetra', 'Torbjorn', 'Tracer', 'Widowmaker', 'Winston', 'Zarya', 'Zenyatta']])
res
Out[9]:
In [10]:
df = pd.DataFrame({"Rank": highRank, "Comp Games": compGames, "Ana": anaHours, "Bastion": bastionHours, "D.Va": dvaHours, "Genji": genjiHours, "Hanzo": hanzoHours, "Junkrat": junkratHours, "Lucio": lucioHours, "McCree": mccreeHours, "Mei": meiHours, "Mercy": mercyHours, "Pharah": pharahHours, "Reaper": reaperHours, "Reinhardt": reinhardtHours, "Roadhog": roadhogHours, "Soldier76": soldier76Hours, "Symmetra": symmetraHours, "Torbjorn": torbjornHours, "Tracer": tracerHours, "Widowmaker": widowmakerHours, "Winston": winstonHours, "Zarya": zaryaHours, "Zenyatta": zenyattaHours})
res = ols(y = df['Rank'], x = df[['Comp Games', 'Ana', 'Bastion', 'D.Va', 'Genji', 'Hanzo', 'Junkrat', 'Lucio', 'McCree', 'Mei', 'Mercy', 'Pharah', 'Reaper', 'Reinhardt', 'Roadhog', 'Soldier76', 'Symmetra', 'Torbjorn', 'Tracer', 'Widowmaker', 'Winston', 'Zarya', 'Zenyatta']])
res
Out[10]:
In [11]:
df = pd.DataFrame({"Rank": rankFiltered, "Average Elims": avgElims, "Total Elims": totalElims, "Most Elims": mostElims})
res = ols(y = df['Rank'], x = df[['Average Elims', 'Total Elims', 'Most Elims']])
res
Out[11]:
In [12]:
df = pd.DataFrame({"Rank": rankFiltered, "Ana": anaHours})
res = ols(y = df['Rank'], x = df[['Ana']])
res
Out[12]:
In [13]:
df = pd.DataFrame({"Rank": rankFiltered, "Bastion": bastionHours})
res = ols(y = df['Rank'], x = df[['Bastion']])
res
Out[13]:
In [14]:
df = pd.DataFrame({"Rank": rankFiltered, "D.Va": dvaHours})
res = ols(y = df['Rank'], x = df[['D.Va']])
res
Out[14]:
In [15]:
df = pd.DataFrame({"Rank": rankFiltered, "Genji": genjiHours})
res = ols(y = df['Rank'], x = df[['Genji']])
res
Out[15]:
In [16]:
df = pd.DataFrame({"Rank": rankFiltered, "Hanzo": hanzoHours})
res = ols(y = df['Rank'], x = df[['Hanzo']])
res
Out[16]:
In [17]:
df = pd.DataFrame({"Rank": rankFiltered, "Junkrat": junkratHours})
res = ols(y = df['Rank'], x = df[['Junkrat']])
res
Out[17]:
In [18]:
df = pd.DataFrame({"Rank": rankFiltered, "Lucio": lucioHours})
res = ols(y = df['Rank'], x = df[['Lucio']])
res
Out[18]:
In [19]:
df = pd.DataFrame({"Rank": rankFiltered, "McCree": mccreeHours})
res = ols(y = df['Rank'], x = df[['McCree']])
res
Out[19]:
In [20]:
df = pd.DataFrame({"Rank": rankFiltered, "Mei": meiHours})
res = ols(y = df['Rank'], x = df[['Mei']])
res
Out[20]:
In [21]:
df = pd.DataFrame({"Rank": rankFiltered, "Mercy": mercyHours})
res = ols(y = df['Rank'], x = df[['Mercy']])
res
Out[21]:
In [22]:
df = pd.DataFrame({"Rank": rankFiltered, "Orisa": orisaHours})
res = ols(y = df['Rank'], x = df[['Orisa']])
res
Out[22]:
In [23]:
df = pd.DataFrame({"Rank": rankFiltered, "Pharah": pharahHours})
res = ols(y = df['Rank'], x = df[['Pharah']])
res
Out[23]:
In [24]:
df = pd.DataFrame({"Rank": rankFiltered, "Reaper": reaperHours})
res = ols(y = df['Rank'], x = df[['Reaper']])
res
Out[24]:
In [25]:
df = pd.DataFrame({"Rank": rankFiltered, "Reinhardt": reinhardtHours})
res = ols(y = df['Rank'], x = df[['Reinhardt']])
res
Out[25]:
In [26]:
df = pd.DataFrame({"Rank": rankFiltered, "Roadhog": roadhogHours})
res = ols(y = df['Rank'], x = df[['Roadhog']])
res
Out[26]:
In [27]:
df = pd.DataFrame({"Rank": rankFiltered, "Soldier76": soldier76Hours})
res = ols(y = df['Rank'], x = df[['Soldier76']])
res
Out[27]:
In [28]:
df = pd.DataFrame({"Rank": rankFiltered, "Sombra": sombraHours})
res = ols(y = df['Rank'], x = df[['Sombra']])
res
In [29]:
df = pd.DataFrame({"Rank": rankFiltered, "Symmetra": symmetraHours})
res = ols(y = df['Rank'], x = df[['Symmetra']])
res
Out[29]:
In [30]:
df = pd.DataFrame({"Rank": rankFiltered, "Torbjorn": torbjornHours})
res = ols(y = df['Rank'], x = df[['Torbjorn']])
res
Out[30]:
In [31]:
df = pd.DataFrame({"Rank": rankFiltered, "Tracer": tracerHours})
res = ols(y = df['Rank'], x = df[['Tracer']])
res
Out[31]:
In [32]:
df = pd.DataFrame({"Rank": rankFiltered, "Widowmaker": widowmakerHours})
res = ols(y = df['Rank'], x = df[['Widowmaker']])
res
Out[32]:
In [33]:
df = pd.DataFrame({"Rank": rankFiltered, "Winston": winstonHours})
res = ols(y = df['Rank'], x = df[['Winston']])
res
Out[33]:
In [34]:
df = pd.DataFrame({"Rank": rankFiltered, "Zarya": zaryaHours})
res = ols(y = df['Rank'], x = df[['Zarya']])
res
Out[34]:
In [35]:
df = pd.DataFrame({"Rank": rankFiltered, "Zenyatta": zenyattaHours})
res = ols(y = df['Rank'], x = df[['Zenyatta']])
res
Out[35]:
In [36]:
rankdata=[x for x in data['rank'] if x <1E100]# is x < 'infinity'
ranks = [x for x in rankdata if x > 0]
import matplotlib.pyplot as plt
%matplotlib inline
plt.plot(rankdata)
plt.show()