Refined search for Pokemon race values using Python

I wanted to find a Pokemon that could use the trick room in a Pokemon match, but I was wondering which Pokemon to use. First of all, when using the trick room, I thought that a Pokemon that could withstand the attack from the opponent would be good because it would be a follower, so I wanted to find a Pokemon with a low race value and high defense and special defense. .. So I came up with the idea of narrowing down the search from csv data using the programming language Python.

Prepare in advance

-Install Excel or Numbers ・ Installation of Anaconda -Installation of Python and Pandas

procedure

① Download and create csv file You can download the csv file of the Pokemon race value from the following URL. https://www.kaggle.com/abcsds/pokemon This csv file does not contain data for 7-8 generation Pokemon. Also, since it is written in English, the name of Pokemon is also in English, so it may be a little difficult to handle.

The 8th generation Pokemon (Pokemon that appeared in the sword shield) took some time to copy the data from the URL below, but I arranged the table on Excel and made it a csv file. https://wiki.ポケモン.com/wiki/種族値一覧_(第八世代)

② Narrow down the race value with Python First, try reading the data from the csv file. Drag the icon of the installed csv file to put it in the file list on the left side of the screen. Next, enter the following code in Anacoda's Jupyter Lab.

import pandas as pd
df = pd.read_csv("Pokemon.csv")
df

Then, the list will be displayed on the screen as shown in the figure below.

スクリーンショット 2020-06-16 14.47.48.png

Next, I would like to narrow down the Esper type Pokemon excluding the legend. Try entering the following code.

df.loc[(df.Legendary == False) & (df["Type 1"] == "Psychic")]

Then, I think that a list of non-legendary Esper type Pokemon is displayed as shown in the screen below.

スクリーンショット 2020-06-16 14.52.30.png

Then, take over the list results narrowed down earlier and enter the following code to search for Pokemon with a defense race value of 60 or more and agility of 65 or less.

df = df.loc[(df.Legendary == False) & (df["Type 1"] == "Psychic")]
df.loc[(df.Defense >= 60) & (df.Speed <= 65)]

As a result of inputting, I think that I narrowed down considerably.

スクリーンショット 2020-06-16 15.01.23.png

Finally, enter the following code to sort the defense race values in descending order and you're done.

df = df.loc[(df.Defense >= 60) & (df.Speed <= 65)]
df.sort_values(by = ['Defense'], ascending = False)
スクリーンショット 2020-06-16 15.04.13.png

In summary, you can easily get the result by entering the following code.

import pandas as pd
df = pd.read_csv("Pokemon.csv")
df = df.loc[(df.Legendary == False) & (df["Type 1"] == "Psychic")]
df = df.loc[(df.Defense >= 60) & (df.Speed <= 65)]
df.sort_values(by = ['Defense'], ascending = False)

Finally

Since it was difficult to understand Pokemon with English names, I also read the csv file with Japanese names created from the list copied from the URL and narrowed it down in the same way. Name the file Pokemon_data.csv and enter the code below to get the result.

import pandas as pd
df = pd.read_csv("Pokemon_data.csv")
df = df.loc[(df.Legend== False) & (df["Type 1"] == "Esper")]
df = df.loc[(df.defense>= 60) & (df.Agility<= 65)]
df.sort_values(by = ['defense'], ascending = False)
スクリーンショット 2020-06-16 15.37.40.png

What I found was that Brimon and Musharna were equally low in quickness and high in defense and special defense, so I interpreted them as candidates for Pokemon to use the trick room.

There are other Pokemon that are ghost type and can use trick rooms, so it may be good to enter the code and search for it as well.

Afterword

You can practice code using Pandas at the URL below. I think it's a good reference for studying programming.

https://www.kaggle.com/learn/pandas

Recommended Posts

Refined search for Pokemon race values using Python
Python pandas: Search for DataFrame using regular expressions
Search Twitter using Python
Search for strings in Python
Search algorithm using word2vec [python]
Try a similar search for Image Search using the Python SDK [Search]
[Excel] Search for duplicate values (characters)
Search for profitable brands using COTOHA
[TouchDesigner] Tips for for statements using python
[Python] Reasons for overriding using super ()
[Python] Multiplication table using for statement
Depth-first search using stack in Python
Dump, restore and query search for Python class instances using mongodb
Notes for using OpenCV on Windows10 Python 3.8.3.
Python> dictionary> values ()> Get All Values by Using values ()
[50 counts] Key transmission using Python for Windows
[python, multiprocessing] Behavior for exceptions when using multiprocessing
Tips for using python + caffe with TSUBAME
Notes for using python (pydev) in eclipse
Search for synonyms from the word list (csv) using Python Japanese WordNet
Search for Pokemon haunting information from Twitter
Search for adsorption structure using Minima Hopping method
vprof --I tried using the profiler for Python
Causal reasoning and causal search with Python (for beginners)
[Python] I searched for the longest Pokemon Shiritori
Zero padding for dynamic variable values in Python
Pass values between pages using Python 3.5 cgi module
Let's search for numerical values by linear search / 2-minute search
Let's make a module for Python using SWIG
2016-10-30 else for Python3> for:
Python: Tips-Swap values
Start using Python
Scraping using Python
Let's analyze Covid-19 (Corona) data using Python [For beginners]
Searching for pixiv tags and saving illustrations using Python
Extendable skeletons for Vim using Python, Click and Jinja2
[Heroku] Memo for deploying Python apps using Heroku on Windows [Python]
Explore Alibaba Cloud Function Compute for DevOps using Python 3.0
Using the National Diet Library Search API in Python
Recursively search for files and directories in Python and output
Memo for building a machine learning environment using Python
[Introduction to Python] How to write repetitive statements using for statements