[PYTHON] I want to get League of Legends data ②

Ready to analyze the data

Last time I looked at the contents of the data one by one, so this time I would like to extract only the data I want from it. (Click here for the previous article https://qiita.com/mattya_527/items/d9861db5e129d92c1637)

environment

As of February 1, 2020 OS:windows10 Anaconda:4.8.1 python:3.7.6

Data preparation

The data I want this time is the number of wins and losses, the number of kills, the number of deaths, the number of assists, the kill involvement rate, the champion used, the champion who played, the lane, CS, the gold earned, the damage done to the champion, the time of the game To go. Game mode is narrowed down to rank.

Looking at what I checked last time,

item Object name Mold
Win or lose win bool
Number of kills kills int
Number of deaths deaths int
Number of assists assists int
champion championId int
lane lane, role str
CS totalMinionsKilled int
Earn gold goldEarned int
Damage to the champion magicDamageDealtToChampions,physicalDamageDealtToChampions,total of trueDamageDealtToChampions int
Game time gameDuration int
Whether it is a ranked game queueId=420 int

Data extraction

First, give out the names of everyone to limit the players to yourself.

for i in range(10):
    match_data["participantIdentities"][i]["player"]
    print(match_data["participantIdentities"][i]["player"]["summonerName"])

image.png (For the time being, the SN of other people is hidden.)

You can see that if you want to limit yourself only, you can judge whether it matches the one defined by name last time.

for i in range(10):
   if match_data["participantIdentities"][i]["player"]["summonerName"] == name: #Does the summoner name match?
      par_Id = match_data["participants"][i]["participantId"]
      print(par_Id) #Output participantId

#par_Output the data that matches Id
if match_data["participants"][par_Id-1]["stats"]["participantId"] == par_Id: #par_Id-1 matches the index
    print(match_data["participants"][par_Id-1]["stats"]["win"]) #Win or lose
    print(match_data["participants"][par_Id-1]["stats"]["kills"]) #Number of kills
    print(match_data["participants"][par_Id-1]["stats"]["deaths"]) #Number of deaths
    print(match_data["participants"][par_Id-1]["stats"]["assists"]) #Number of assists
    print(match_data["participants"][par_Id-1]["championId"]) #Champion used
    print(match_data["participants"][par_Id-1]["timeline"]["lane"]) #lane
    print(match_data["participants"][par_Id-1]["timeline"]["role"]) #roll
    print(match_data["participants"][par_Id-1]["stats"]["totalMinionsKilled"]) #CS **Is there anything other than minions and jungle creep that is necessary for CS because it is not enough for CS seen in OPGG?
    print(match_data["participants"][par_Id-1]["stats"]["goldEarned"]) #Earn gold
    print(match_data["participants"][par_Id-1]["stats"]["magicDamageDealtToChampions"] + match_data["participants"][par_Id-1]["stats"]["physicalDamageDealtToChampions"] + match_data["participants"][par_Id-1]["stats"]["trueDamageDealtToChampions"]) #Damage to the champion
    print(match_data["participants"][par_Id-1]["teamId"]) #100 is the blue side, 200 is the red side
    print(match_data["gameDuration"]) #Game time(Seconds)

image.png

I want to narrow down to ranked games, so I will make that judgment. Rank has queueId 420, so

if match_data["queueId"] == 420:

This can be identified. The reason why I want to narrow down to rank is that unless it is a rank game, rolls and lanes will be NONE and I can not collect the desired data.

Summary

This time, I was able to get the information I wanted by picking up the data for my one game. Next, I would like to upload this data to the database. That's why I will study the database and start again.

Recommended Posts

I want to get League of Legends data ③
I want to get League of Legends data ②
I want to get League of Legends data ①
I want to create a web application that uses League of Legends data ①
I want to get the operation information of yahoo route
Keras I want to get the output of any layer !!
I want to get custom data attributes of html as elements using Python Selenium
I want to get the name of the function / method being executed
[Note] I want to completely preprocess the data of the Titanic issue-Age version-
Anyway, I want to check JSON data easily
I tried to get CloudWatch data with Python
I want to customize the appearance of zabbix
I want to get the path of the directory where the running file is stored.
I want to get / execute variables / functions / classes of external files from Python
Library for "I want to do that" of data science on Jupyter Notebook
I want to detect images of cats from Instagram
I want to give a group_id to a pandas data frame
I want to fully understand the basics of Bokeh
I want to install a package of Php Redis
I tried to analyze J League data with Python
[Python] I tried to get Json of squid ring 2
I want to say that there is data preprocessing ~
I want to increase the security of ssh connections
I want to solve Sudoku (Sudoku)
I want to use a python data source in Re: Dash to get query results
I want to be able to analyze data with Python (Part 3)
I tried to get the location information of Odakyu Bus
I want to specify another version of Python with pyvenv
I want to be able to analyze data with Python (Part 1)
[Python] I want to get a common set between numpy
I want to start a lot of processes from python
I want to use only the normalization process of SudachiPy
NikuGan ~ I want to see a lot of delicious meat! !!
I want to color black-and-white photos of memories with GAN
I want to be able to analyze data with Python (Part 2)
I want to judge the authenticity of the elements of numpy array
I want to know the features of Python and pip
I want to know the legend of the IT technology world
How to get an overview of your data in Pandas
I tried to get data from AS / 400 quickly using pypyodbc
I sent the data of Raspberry Pi to GCP (free)
I want to get rid of import warnings from Pyright and pylint in VS Code
I want to scrape images to learn
I want to do ○○ with Pandas
I want to copy yolo annotations
I want to debug with Python
I want to manually assign the training parameters of the [Pytorch] model
I tried to get a database of horse racing using Pandas
I want to read the html version of "OpenCV-Python Tutorials" OpenCV 3.1 version
I want to output the beginning of the next month with Python
Comparison of GCP computing services [I want to use it serverless]
I want to use both key and value of Python iterator
I tried to get a list of AMI Names using Boto3
I want to acquire and list Japanese stock data without scraping
I want to check the position of my face with OpenCV!
Python techniques for those who want to get rid of beginners
I want to know the population of each country in the world.
[Python] I tried to get various information using YouTube Data API!
I want to convert vertically held data (long type) to horizontally held data (wide type)
I tried to get data from AS / 400 quickly using pypyodbc Preparation 1
I want to pin Spyder to the taskbar