In [142]:
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")
data = pd.read_json("OverwatchTotal.json")
In [143]:
data = data[pd.notnull(data['rank'])]
len(data)
Out[143]:
In [144]:
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', {})]
[len(rank), len(level), len(comp), len(qp), len(heroes)]
Out[144]:
In [145]:
def getCompWins(x):
b = x.get('total', {})
return(b.get('wins', {}))
def getWinRate(x):
b = x.get('total', {})
return(b.get('rate', {}))
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)
def filterFloats(x):
if type(x) == float:
return(x)
else:
return(0)
def filterInts(x):
if type(x) == int:
return(x)
else:
return(0)
In [146]:
compWins = [getCompWins(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]
rank=[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]
avg = [getAvgElims(x) for x in comp]
total = [getTotalElims(x) for x in comp]
most = [getMostElims(x) for x in comp]
avgElims = [filterFloats(x) for x in avg]
totalElims = [filterInts(x) for x in total]
mostElims = [filterInts(x) for x in most]
winRate = [getWinRate(x) for x in comp]
In [147]:
df = pd.DataFrame({"Rank": rank, "Level": level, "Comp Wins": compWins, "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, "Sombra": sombraHours, "Symmetra": symmetraHours, "Torbjorn": torbjornHours, "Tracer": tracerHours, "Widowmaker": widowmakerHours, "Winston": winstonHours, "Zarya": zaryaHours, "Zenyatta": zenyattaHours})
res = ols(y = df['Rank'], x = df[['Level','Comp Wins', 'Quick Games', 'Ana', 'Bastion', 'D.Va', 'Genji', 'Hanzo', 'Junkrat', 'Lucio', 'McCree', 'Mei', 'Mercy', 'Orisa', 'Pharah', 'Reaper', 'Reinhardt', 'Roadhog', 'Soldier76', 'Sombra', 'Symmetra', 'Torbjorn', 'Tracer', 'Widowmaker', 'Winston', 'Zarya', 'Zenyatta']])
res
Out[147]:
In [148]:
df = pd.DataFrame({"Rank": rank, "Level": level, "Comp Wins": compWins, "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, "Sombra": sombraHours, "Symmetra": symmetraHours, "Torbjorn": torbjornHours, "Tracer": tracerHours, "Widowmaker": widowmakerHours, "Winston": winstonHours, "Zarya": zaryaHours, "Zenyatta": zenyattaHours})
res = ols(y = df['Rank'], x = df[['Level','Comp Wins', 'Quick Games', 'Ana', 'Bastion', 'D.Va', 'Genji', 'Hanzo', 'Junkrat', 'Lucio', 'McCree', 'Mei', 'Mercy', 'Orisa', 'Pharah', 'Reaper', 'Reinhardt', 'Roadhog', 'Soldier76', 'Sombra', 'Symmetra', 'Torbjorn', 'Tracer', 'Widowmaker', 'Winston', 'Zarya', 'Zenyatta']])
res
Out[148]:
In [149]:
df = pd.DataFrame({"Rank": rank, "Comp Wins": compWins, "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, "Sombra": sombraHours, "Symmetra": symmetraHours, "Torbjorn": torbjornHours, "Tracer": tracerHours, "Widowmaker": widowmakerHours, "Winston": winstonHours, "Zarya": zaryaHours, "Zenyatta": zenyattaHours})
res = ols(y = df['Rank'], x = df[['Comp Wins', 'Ana', 'Bastion', 'D.Va', 'Genji', 'Hanzo', 'Junkrat', 'Lucio', 'McCree', 'Mei', 'Mercy', 'Pharah', 'Reaper', 'Reinhardt', 'Roadhog', 'Soldier76', 'Sombra', 'Symmetra', 'Torbjorn', 'Tracer', 'Widowmaker', 'Winston', 'Zarya', 'Zenyatta']])
res
Out[149]:
In [150]:
df = pd.DataFrame({"Rank": lowRank, "Comp Wins": compWins, "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, "Sombra": sombraHours, "Symmetra": symmetraHours, "Torbjorn": torbjornHours, "Tracer": tracerHours, "Widowmaker": widowmakerHours, "Winston": winstonHours, "Zarya": zaryaHours, "Zenyatta": zenyattaHours})
res = ols(y = df['Rank'], x = df[['Comp Wins', 'Ana', 'Bastion', 'D.Va', 'Genji', 'Hanzo', 'Junkrat', 'Lucio', 'McCree', 'Mei', 'Mercy', 'Pharah', 'Reaper', 'Reinhardt', 'Roadhog', 'Soldier76', 'Sombra', 'Symmetra', 'Torbjorn', 'Tracer', 'Widowmaker', 'Winston', 'Zarya', 'Zenyatta']])
res
Out[150]:
In [151]:
df = pd.DataFrame({"Rank": medRank, "Comp Wins": compWins, "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, "Sombra": sombraHours, "Symmetra": symmetraHours, "Torbjorn": torbjornHours, "Tracer": tracerHours, "Widowmaker": widowmakerHours, "Winston": winstonHours, "Zarya": zaryaHours, "Zenyatta": zenyattaHours})
res = ols(y = df['Rank'], x = df[['Comp Wins', 'Ana', 'Bastion', 'D.Va', 'Genji', 'Hanzo', 'Junkrat', 'Lucio', 'McCree', 'Mei', 'Mercy', 'Pharah', 'Reaper', 'Reinhardt', 'Roadhog', 'Soldier76', 'Sombra', 'Symmetra', 'Torbjorn', 'Tracer', 'Widowmaker', 'Winston', 'Zarya', 'Zenyatta']])
res
Out[151]:
In [152]:
df = pd.DataFrame({"Rank": highRank, "Comp Wins": compWins, "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, "Sombra": sombraHours, "Symmetra": symmetraHours, "Torbjorn": torbjornHours, "Tracer": tracerHours, "Widowmaker": widowmakerHours, "Winston": winstonHours, "Zarya": zaryaHours, "Zenyatta": zenyattaHours})
res = ols(y = df['Rank'], x = df[['Comp Wins', 'Ana', 'Bastion', 'D.Va', 'Genji', 'Hanzo', 'Junkrat', 'Lucio', 'McCree', 'Mei', 'Mercy', 'Pharah', 'Reaper', 'Reinhardt', 'Roadhog', 'Soldier76', 'Sombra', 'Symmetra', 'Torbjorn', 'Tracer', 'Widowmaker', 'Winston', 'Zarya', 'Zenyatta']])
res
Out[152]:
In [153]:
df = pd.DataFrame({"Rank": rank, "Avg Elims": avgElims, "Total Elims": totalElims, "Most Elims": mostElims})
res = ols(y = df['Rank'], x = df[['Avg Elims', 'Total Elims', 'Most Elims']])
res
Out[153]:
In [154]:
df = pd.DataFrame({"Avg Elims": avgElims, "Genji": genjiHours, "McCree": mccreeHours, "Pharah": pharahHours, "Reaper": reaperHours, "Soldier76": soldier76Hours, "Sombra": sombraHours, "Tracer": tracerHours})
res = ols(y = df['Avg Elims'], x = df[['Genji', 'McCree', 'Pharah', 'Reaper', 'Soldier76', 'Sombra', 'Tracer']])
res
Out[154]:
In [155]:
df = pd.DataFrame({"Avg Elims": avgElims, "Bastion": bastionHours, "Hanzo": hanzoHours, "Junkrat": junkratHours, "Mei": meiHours, "Torbjorn": torbjornHours, "Widowmaker": widowmakerHours, })
res = ols(y = df['Avg Elims'], x = df[['Bastion', 'Hanzo', 'Junkrat', 'Mei', 'Torbjorn', 'Widowmaker']])
res
Out[155]:
In [156]:
df = pd.DataFrame({"Avg Elims": avgElims, "D.Va": dvaHours, "Reinhardt": reinhardtHours, "Roadhog": roadhogHours, "Winston": winstonHours, "Zarya": zaryaHours})
res = ols(y = df['Avg Elims'], x = df[['D.Va', 'Reinhardt', 'Roadhog', 'Winston', 'Zarya']])
res
Out[156]:
In [157]:
df = pd.DataFrame({"Avg Elims": avgElims, "Ana": anaHours, "Lucio": lucioHours, "Mercy": mercyHours, "Symmetra": symmetraHours, "Zenyatta": zenyattaHours})
res = ols(y = df['Avg Elims'], x = df[['Ana', 'Lucio', 'Mercy', 'Symmetra', 'Zenyatta']])
res
Out[157]:
In [158]:
df = pd.DataFrame({"Rank": rank, "Ana": anaHours})
res = ols(y = df['Rank'], x = df[['Ana']])
res
Out[158]:
In [159]:
df = pd.DataFrame({"Rank": rank, "Bastion": bastionHours})
res = ols(y = df['Rank'], x = df[['Bastion']])
res
Out[159]:
In [160]:
df = pd.DataFrame({"Rank": rank, "D.Va": dvaHours})
res = ols(y = df['Rank'], x = df[['D.Va']])
res
Out[160]:
In [161]:
df = pd.DataFrame({"Rank": rank, "Genji": genjiHours})
res = ols(y = df['Rank'], x = df[['Genji']])
res
Out[161]:
In [162]:
df = pd.DataFrame({"Rank": rank, "Hanzo": hanzoHours})
res = ols(y = df['Rank'], x = df[['Hanzo']])
res
Out[162]:
In [163]:
df = pd.DataFrame({"Rank": rank, "Junkrat": junkratHours})
res = ols(y = df['Rank'], x = df[['Junkrat']])
res
Out[163]:
In [164]:
df = pd.DataFrame({"Rank": rank, "Lucio": lucioHours})
res = ols(y = df['Rank'], x = df[['Lucio']])
res
Out[164]:
In [165]:
df = pd.DataFrame({"Rank": rank, "McCree": mccreeHours})
res = ols(y = df['Rank'], x = df[['McCree']])
res
Out[165]:
In [166]:
df = pd.DataFrame({"Rank": rank, "Mei": meiHours})
res = ols(y = df['Rank'], x = df[['Mei']])
res
Out[166]:
In [167]:
df = pd.DataFrame({"Rank": rank, "Mercy": mercyHours})
res = ols(y = df['Rank'], x = df[['Mercy']])
res
Out[167]:
In [168]:
df = pd.DataFrame({"Rank": rank, "Orisa": orisaHours})
res = ols(y = df['Rank'], x = df[['Orisa']])
res
Out[168]:
In [169]:
df = pd.DataFrame({"Rank": rank, "Pharah": pharahHours})
res = ols(y = df['Rank'], x = df[['Pharah']])
res
Out[169]:
In [170]:
df = pd.DataFrame({"Rank": rank, "Reaper": reaperHours})
res = ols(y = df['Rank'], x = df[['Reaper']])
res
Out[170]:
In [171]:
df = pd.DataFrame({"Rank": rank, "Reinhardt": reinhardtHours})
res = ols(y = df['Rank'], x = df[['Reinhardt']])
res
Out[171]:
In [172]:
df = pd.DataFrame({"Rank": rank, "Roadhog": roadhogHours})
res = ols(y = df['Rank'], x = df[['Roadhog']])
res
Out[172]:
In [173]:
df = pd.DataFrame({"Rank": rank, "Soldier76": soldier76Hours})
res = ols(y = df['Rank'], x = df[['Soldier76']])
res
Out[173]:
In [174]:
df = pd.DataFrame({"Rank": rank, "Sombra": sombraHours})
res = ols(y = df['Rank'], x = df[['Sombra']])
res
Out[174]:
In [175]:
df = pd.DataFrame({"Rank": rank, "Symmetra": symmetraHours})
res = ols(y = df['Rank'], x = df[['Symmetra']])
res
Out[175]:
In [176]:
df = pd.DataFrame({"Rank": rank, "Torbjorn": torbjornHours})
res = ols(y = df['Rank'], x = df[['Torbjorn']])
res
Out[176]:
In [177]:
df = pd.DataFrame({"Rank": rank, "Tracer": tracerHours})
res = ols(y = df['Rank'], x = df[['Tracer']])
res
Out[177]:
In [178]:
df = pd.DataFrame({"Rank": rank, "Widowmaker": widowmakerHours})
res = ols(y = df['Rank'], x = df[['Widowmaker']])
res
Out[178]:
In [179]:
df = pd.DataFrame({"Rank": rank, "Winston": winstonHours})
res = ols(y = df['Rank'], x = df[['Winston']])
res
Out[179]:
In [180]:
df = pd.DataFrame({"Rank": rank, "Zarya": zaryaHours})
res = ols(y = df['Rank'], x = df[['Zarya']])
res
Out[180]:
In [181]:
df = pd.DataFrame({"Rank": rank, "Zenyatta": zenyattaHours})
res = ols(y = df['Rank'], x = df[['Zenyatta']])
res
Out[181]:
In [182]:
import matplotlib.pyplot as plt
%matplotlib inline
# bar = plt.bar(rank, avgElims)
plt.hist(rank, 100)
# plt.plot(rank)
plt.show()
# bar
# plt.show(bar)