摘要:
LPL(League of Legends Pro League),中国大陆最高级别的英雄联盟职业比赛,是中国大陆赛区通往每年季中冠军赛和全球总决赛的唯一渠道。相信大部分小伙伴对LPL的参赛队伍都不陌生,那今天就来分析一下这些参赛队伍的数据。
问题:
打比赛的时候,选择蓝方胜率是否是一定高于红方?EDG、WE、RNG以及像国民老公的IG这些战队胜率如何?不同的战队特点是什么呢?某个时段的战队战绩排行又是什么情况?
分析:
1、导入数据并修改字段名
import numpy as np import pandas as pd import seaborn as snsimport matplotlib.pyplot as pltfrom datetime import date, timedelta, datetimefrom pyecharts import Bar,Pie,Line,Geo,Map,Style,WordCloudplt.rc("font", size=14)plt.rcParams['savefig.dpi'] = 100 #图片像素plt.rcParams['figure.dpi'] = 100 #分辨率Data = pd.read_csv('C:/Users/18030/Desktop/LOL.csv')Data.rename(columns={'战队':'Team','攻击':'Attack',"法术":"Magic","防御":"Defence","团战":"Group","机动":"Flex","是否红方":"Is_Red","是否获胜":"IS_V"},inplace=True)Data.head()
不同队伍选择红方,蓝方的输赢比分析
from pyecharts import BarData_1 = pd.pivot_table(Data,values='IS_V',index='Team',columns='Is_Red',aggfunc='sum')Data_1.rename(columns={0:"NO",1:"YES"},inplace=True)attr = Data_1.index.tolist()v1 = Data_1['NO'].values.tolist()v2 = Data_1['YES'].values.tolist()bar = Bar("")bar.add("YES", attr, v2, is_stack=True)bar.add("NO", attr, v1, is_stack=True)bar
可视化结果:
分析结果:
不同队伍的打法特点是怎样的呢?
from pyecharts import RadarData_2 = Data.groupby('Team').mean().stack()EDG_VALUE = [Data_2['EDG'][:5].values.tolist()]WE_VALUE = [Data_2['WE'][:5].values.tolist()]RNG_VALUE = [Data_2['RNG'][:5].values.tolist()]radar = Radar()c_schema= [ {"name": "Attack", "max": 55, "min": 53}, {"name": "Magic", "max": 52.8, "min": 50}, {"name": "Defence", "max": 55, "min": 52}, {"name": "Group", "max": 76, "min":72}, {"name": "Flex", "max": 68, "min":64} ]radar.config(c_schema=c_schema, shape='circle')radar.add("EDG", EDG_VALUE, is_splitline=True, is_axisline_show=True,line_width =2 )radar.add("WE", WE_VALUE, label_color=["#4e79a7"],item_color="#000",line_width=2)radar.add("RNG", RNG_VALUE, label_color=['rgba(443,23,112,121)'],item_color='rgba(413,123,23,412)',line_width=2)radar
说明:这里只画出RNG、EDG、WE的打法特点。
可视化结果:
很明显的看出来这三只队伍的打法特点:
某个时段的战队战绩排行又是什么情况呢?
from pyecharts import BarData_3 = Data.groupby('Team').sum()Data_4 = Data_3['IS_V']Data_4 = Data_4.sort_values(ascending=False)attr = Data_4.index.values.tolist()v = Data_4.values.tolist()bar = Bar()bar.use_theme('dark')bar.add("战队胜场排行榜",attr,v)bar
可视化结果:
分析结果:
不同战队的胜率如何?
from pyecharts import PieData_7 = Data.groupby('Team').sum()Index = Data_7.indexALL_COUNT = np.array([len(Data[Data.Team == i ]) for i in Index])ALL_WIN =Data_7.IS_V.valuesWIN_PER = ALL_WIN/ALL_COUNTLOS_PER = 1 - WIN_PERData_8 = pd.DataFrame(index=Index,columns=['WIN_PER','LOS_PER'])Data_8['WIN_PER'] = WIN_PER*100Data_8['LOS_PER'] = LOS_PER*100Data_8.sort_values(by='WIN_PER',ascending=False,inplace=True)pie = Pie(title_pos='center')style = Style()pie_style = style.add( label_pos="center", is_label_show=True, label_text_color=None)pie.add( "", ["EDG", ""], Data_8.iloc[0].values.tolist(), center=[10, 30], radius=[18, 24], **pie_style)pie.add( "", ["RNG", ""], Data_8.iloc[1].values.tolist(), center=[30, 30], radius=[18, 24], **pie_style)pie.add( "", ["WE", ""], Data_8.iloc[2].values.tolist(), center=[50, 30], radius=[18, 24], **pie_style)pie.add( "", ["IG", ""], Data_8.iloc[3].values.tolist(), center=[70, 30], radius=[18, 24], **pie_style)pie.add( "", ["OMG", ""], Data_8.iloc[4].values.tolist(), center=[90, 30], radius=[18, 24], **pie_style)pie.add( "", ["NB", ""], Data_8.iloc[5].values.tolist(), center=[10, 70], radius=[18, 24], **pie_style)pie.add( "", ["JDG", ""], Data_8.iloc[6].values.tolist(), center=[30, 70], radius=[18, 24], **pie_style)pie.add( "", ["SNG", ""], Data_8.iloc[7].values.tolist(), center=[50, 70], radius=[18, 24], **pie_style)pie.add( "", ["LGD", ""], Data_8.iloc[8].values.tolist(), center=[70, 70], radius=[18, 24], **pie_style)pie.add( "", ["DAN", ""], Data_8.iloc[9].values.tolist(), center=[90, 70], radius=[18, 24], **pie_style)pie
可视化结果: