{ "cells": [ { "cell_type": "markdown", "id": "4f740ff5", "metadata": {}, "source": [ "# pandas: Quizzes" ] }, { "cell_type": "code", "execution_count": 1, "id": "c2dd5f19", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.535230Z", "iopub.status.busy": "2025-09-02T18:59:27.535065Z", "iopub.status.idle": "2025-09-02T18:59:27.740596Z", "shell.execute_reply": "2025-09-02T18:59:27.740111Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "markdown", "id": "9692a229", "metadata": {}, "source": [ "## Loading data into Pandas DataFrame\n", "The dataset is from [Kaggle - Pokemon](https://www.kaggle.com/datasets/abcsds/pokemon)." ] }, { "cell_type": "code", "execution_count": 2, "id": "17dcdfe2", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.742578Z", "iopub.status.busy": "2025-09-02T18:59:27.742391Z", "iopub.status.idle": "2025-09-02T18:59:27.747099Z", "shell.execute_reply": "2025-09-02T18:59:27.746437Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [], "source": [ "df = pd.read_csv('data/Pokemon.csv')" ] }, { "cell_type": "markdown", "id": "e4cb58a5", "metadata": {}, "source": [ "## 1. Import the pandas library as pd." ] }, { "cell_type": "code", "execution_count": 3, "id": "90d54534", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.748524Z", "iopub.status.busy": "2025-09-02T18:59:27.748409Z", "iopub.status.idle": "2025-09-02T18:59:27.750734Z", "shell.execute_reply": "2025-09-02T18:59:27.750293Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "markdown", "id": "6e0ccce3", "metadata": {}, "source": [ "## 2. Read CSV into df" ] }, { "cell_type": "code", "execution_count": 4, "id": "8068ab9a", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.752033Z", "iopub.status.busy": "2025-09-02T18:59:27.751919Z", "iopub.status.idle": "2025-09-02T18:59:27.755476Z", "shell.execute_reply": "2025-09-02T18:59:27.755076Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [], "source": [ "df = pd.read_csv('data/Pokemon.csv')" ] }, { "cell_type": "markdown", "id": "c6952157", "metadata": {}, "source": [ "## 3. Show first 5 rows" ] }, { "cell_type": "code", "execution_count": 5, "id": "2ab20bad", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.756831Z", "iopub.status.busy": "2025-09-02T18:59:27.756716Z", "iopub.status.idle": "2025-09-02T18:59:27.764298Z", "shell.execute_reply": "2025-09-02T18:59:27.763883Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
01BulbasaurGrassPoison3184549496565451False
12IvysaurGrassPoison4056062638080601False
23VenusaurGrassPoison525808283100100801False
33VenusaurMega VenusaurGrassPoison62580100123122120801False
44CharmanderFireNaN3093952436050651False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "0 1 Bulbasaur Grass Poison 318 45 49 49 \n", "1 2 Ivysaur Grass Poison 405 60 62 63 \n", "2 3 Venusaur Grass Poison 525 80 82 83 \n", "3 3 VenusaurMega Venusaur Grass Poison 625 80 100 123 \n", "4 4 Charmander Fire NaN 309 39 52 43 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "0 65 65 45 1 False \n", "1 80 80 60 1 False \n", "2 100 100 80 1 False \n", "3 122 120 80 1 False \n", "4 60 50 65 1 False " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head(5)" ] }, { "cell_type": "markdown", "id": "4d4c988d", "metadata": {}, "source": [ "## 4. Show last 3 rows" ] }, { "cell_type": "code", "execution_count": 6, "id": "97a0493e", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.765616Z", "iopub.status.busy": "2025-09-02T18:59:27.765499Z", "iopub.status.idle": "2025-09-02T18:59:27.770389Z", "shell.execute_reply": "2025-09-02T18:59:27.769864Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
797720HoopaHoopa ConfinedPsychicGhost6008011060150130706True
798720HoopaHoopa UnboundPsychicDark6808016060170130806True
799721VolcanionFireWater6008011012013090706True
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "797 720 HoopaHoopa Confined Psychic Ghost 600 80 110 60 \n", "798 720 HoopaHoopa Unbound Psychic Dark 680 80 160 60 \n", "799 721 Volcanion Fire Water 600 80 110 120 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "797 150 130 70 6 True \n", "798 170 130 80 6 True \n", "799 130 90 70 6 True " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.tail(3)" ] }, { "cell_type": "markdown", "id": "4e204ad3", "metadata": {}, "source": [ "## 5. Show all column names" ] }, { "cell_type": "code", "execution_count": 7, "id": "59df7a9a", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.771695Z", "iopub.status.busy": "2025-09-02T18:59:27.771580Z", "iopub.status.idle": "2025-09-02T18:59:27.774332Z", "shell.execute_reply": "2025-09-02T18:59:27.773906Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/plain": [ "Index(['#', 'Name', 'Type 1', 'Type 2', 'Total', 'HP', 'Attack', 'Defense',\n", " 'Sp. Atk', 'Sp. Def', 'Speed', 'Generation', 'Legendary'],\n", " dtype='object')" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.columns" ] }, { "cell_type": "markdown", "id": "8c488405", "metadata": {}, "source": [ "## 6. Select rows index 10 to 15" ] }, { "cell_type": "code", "execution_count": 8, "id": "99d485d9", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.775668Z", "iopub.status.busy": "2025-09-02T18:59:27.775557Z", "iopub.status.idle": "2025-09-02T18:59:27.780445Z", "shell.execute_reply": "2025-09-02T18:59:27.780047Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
108WartortleWaterNaN4055963806580581False
119BlastoiseWaterNaN530798310085105781False
129BlastoiseMega BlastoiseWaterNaN63079103120135115781False
1310CaterpieBugNaN1954530352020451False
1411MetapodBugNaN2055020552525301False
1512ButterfreeBugFlying3956045509080701False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "10 8 Wartortle Water NaN 405 59 63 80 \n", "11 9 Blastoise Water NaN 530 79 83 100 \n", "12 9 BlastoiseMega Blastoise Water NaN 630 79 103 120 \n", "13 10 Caterpie Bug NaN 195 45 30 35 \n", "14 11 Metapod Bug NaN 205 50 20 55 \n", "15 12 Butterfree Bug Flying 395 60 45 50 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "10 65 80 58 1 False \n", "11 85 105 78 1 False \n", "12 135 115 78 1 False \n", "13 20 20 45 1 False \n", "14 25 25 30 1 False \n", "15 90 80 70 1 False " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.iloc[10:16]" ] }, { "cell_type": "markdown", "id": "a8f73849", "metadata": {}, "source": [ "## 7. Select row index 50" ] }, { "cell_type": "code", "execution_count": 9, "id": "ca123aca", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.781639Z", "iopub.status.busy": "2025-09-02T18:59:27.781524Z", "iopub.status.idle": "2025-09-02T18:59:27.784620Z", "shell.execute_reply": "2025-09-02T18:59:27.784217Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/plain": [ "# 45\n", "Name Vileplume\n", "Type 1 Grass\n", "Type 2 Poison\n", "Total 490\n", "HP 75\n", "Attack 80\n", "Defense 85\n", "Sp. Atk 110\n", "Sp. Def 90\n", "Speed 50\n", "Generation 1\n", "Legendary False\n", "Name: 50, dtype: object" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.iloc[50]" ] }, { "cell_type": "markdown", "id": "dd665e14", "metadata": {}, "source": [ "## 8. Filter rows Type 1 == Grass" ] }, { "cell_type": "code", "execution_count": 10, "id": "73530fde", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.785992Z", "iopub.status.busy": "2025-09-02T18:59:27.785854Z", "iopub.status.idle": "2025-09-02T18:59:27.791225Z", "shell.execute_reply": "2025-09-02T18:59:27.790805Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
01BulbasaurGrassPoison3184549496565451False
12IvysaurGrassPoison4056062638080601False
23VenusaurGrassPoison525808283100100801False
33VenusaurMega VenusaurGrassPoison62580100123122120801False
4843OddishGrassPoison3204550557565301False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "0 1 Bulbasaur Grass Poison 318 45 49 49 \n", "1 2 Ivysaur Grass Poison 405 60 62 63 \n", "2 3 Venusaur Grass Poison 525 80 82 83 \n", "3 3 VenusaurMega Venusaur Grass Poison 625 80 100 123 \n", "48 43 Oddish Grass Poison 320 45 50 55 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "0 65 65 45 1 False \n", "1 80 80 60 1 False \n", "2 100 100 80 1 False \n", "3 122 120 80 1 False \n", "48 75 65 30 1 False " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[df['Type 1'] == 'Grass'].head()" ] }, { "cell_type": "markdown", "id": "fe6724cf", "metadata": {}, "source": [ "## 9. Filter rows HP > 100" ] }, { "cell_type": "code", "execution_count": 11, "id": "c535d6c0", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.792495Z", "iopub.status.busy": "2025-09-02T18:59:27.792389Z", "iopub.status.idle": "2025-09-02T18:59:27.797572Z", "shell.execute_reply": "2025-09-02T18:59:27.797157Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
4439JigglypuffNormalFairy27011545204525201False
4540WigglytuffNormalFairy43514070458550451False
9689MukPoisonNaN5001051057565100501False
120112RhydonGroundRock4851051301204545401False
121113ChanseyNormalNaN4502505535105501False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense Sp. Atk \\\n", "44 39 Jigglypuff Normal Fairy 270 115 45 20 45 \n", "45 40 Wigglytuff Normal Fairy 435 140 70 45 85 \n", "96 89 Muk Poison NaN 500 105 105 75 65 \n", "120 112 Rhydon Ground Rock 485 105 130 120 45 \n", "121 113 Chansey Normal NaN 450 250 5 5 35 \n", "\n", " Sp. Def Speed Generation Legendary \n", "44 25 20 1 False \n", "45 50 45 1 False \n", "96 100 50 1 False \n", "120 45 40 1 False \n", "121 105 50 1 False " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[df['HP'] > 100].head()" ] }, { "cell_type": "markdown", "id": "df1dfb62", "metadata": {}, "source": [ "## 10. Filter rows Name contains chu" ] }, { "cell_type": "code", "execution_count": 12, "id": "fec0dfd7", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.798809Z", "iopub.status.busy": "2025-09-02T18:59:27.798696Z", "iopub.status.idle": "2025-09-02T18:59:27.804078Z", "shell.execute_reply": "2025-09-02T18:59:27.803656Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
3025PikachuElectricNaN3203555405050901False
3126RaichuElectricNaN48560905590801101False
186172PichuElectricNaN2052040153535602False
257238SmoochumIcePsychic3054530158565652False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense Sp. Atk \\\n", "30 25 Pikachu Electric NaN 320 35 55 40 50 \n", "31 26 Raichu Electric NaN 485 60 90 55 90 \n", "186 172 Pichu Electric NaN 205 20 40 15 35 \n", "257 238 Smoochum Ice Psychic 305 45 30 15 85 \n", "\n", " Sp. Def Speed Generation Legendary \n", "30 50 90 1 False \n", "31 80 110 1 False \n", "186 35 60 2 False \n", "257 65 65 2 False " ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[df['Name'].str.contains('chu')].head()" ] }, { "cell_type": "markdown", "id": "efc47cf2", "metadata": {}, "source": [ "## 11. Sort by Attack descending" ] }, { "cell_type": "code", "execution_count": 13, "id": "82e76329", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.805358Z", "iopub.status.busy": "2025-09-02T18:59:27.805245Z", "iopub.status.idle": "2025-09-02T18:59:27.810508Z", "shell.execute_reply": "2025-09-02T18:59:27.810080Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
163150MewtwoMega Mewtwo XPsychicFighting7801061901001541001301True
232214HeracrossMega HeracrossBugFighting6008018511540105752False
429386DeoxysAttack FormePsychicNaN6005018020180201503True
426384RayquazaMega RayquazaDragonFlying7801051801001801001153True
424383GroudonPrimal GroudonGroundFire77010018016015090903True
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack \\\n", "163 150 MewtwoMega Mewtwo X Psychic Fighting 780 106 190 \n", "232 214 HeracrossMega Heracross Bug Fighting 600 80 185 \n", "429 386 DeoxysAttack Forme Psychic NaN 600 50 180 \n", "426 384 RayquazaMega Rayquaza Dragon Flying 780 105 180 \n", "424 383 GroudonPrimal Groudon Ground Fire 770 100 180 \n", "\n", " Defense Sp. Atk Sp. Def Speed Generation Legendary \n", "163 100 154 100 130 1 True \n", "232 115 40 105 75 2 False \n", "429 20 180 20 150 3 True \n", "426 100 180 100 115 3 True \n", "424 160 150 90 90 3 True " ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.sort_values('Attack', ascending=False).head()" ] }, { "cell_type": "markdown", "id": "fe2f4be5", "metadata": {}, "source": [ "## 12. Reset index" ] }, { "cell_type": "code", "execution_count": 14, "id": "8a229215", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.811763Z", "iopub.status.busy": "2025-09-02T18:59:27.811648Z", "iopub.status.idle": "2025-09-02T18:59:27.816484Z", "shell.execute_reply": "2025-09-02T18:59:27.816086Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
01BulbasaurGrassPoison3184549496565451False
12IvysaurGrassPoison4056062638080601False
23VenusaurGrassPoison525808283100100801False
33VenusaurMega VenusaurGrassPoison62580100123122120801False
44CharmanderFireNaN3093952436050651False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "0 1 Bulbasaur Grass Poison 318 45 49 49 \n", "1 2 Ivysaur Grass Poison 405 60 62 63 \n", "2 3 Venusaur Grass Poison 525 80 82 83 \n", "3 3 VenusaurMega Venusaur Grass Poison 625 80 100 123 \n", "4 4 Charmander Fire NaN 309 39 52 43 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "0 65 65 45 1 False \n", "1 80 80 60 1 False \n", "2 100 100 80 1 False \n", "3 122 120 80 1 False \n", "4 60 50 65 1 False " ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "new_df = df.reset_index(drop=True)\n", "new_df.head()" ] }, { "cell_type": "markdown", "id": "1337ef67", "metadata": {}, "source": [ "## 13. Select columns Name, Type 1, HP" ] }, { "cell_type": "code", "execution_count": 15, "id": "e314e495", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.817777Z", "iopub.status.busy": "2025-09-02T18:59:27.817655Z", "iopub.status.idle": "2025-09-02T18:59:27.822020Z", "shell.execute_reply": "2025-09-02T18:59:27.821656Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
NameType 1HP
0BulbasaurGrass45
1IvysaurGrass60
2VenusaurGrass80
3VenusaurMega VenusaurGrass80
4CharmanderFire39
\n", "
" ], "text/plain": [ " Name Type 1 HP\n", "0 Bulbasaur Grass 45\n", "1 Ivysaur Grass 60\n", "2 Venusaur Grass 80\n", "3 VenusaurMega Venusaur Grass 80\n", "4 Charmander Fire 39" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[['Name', 'Type 1', 'HP']].head()" ] }, { "cell_type": "markdown", "id": "2158d684", "metadata": {}, "source": [ "## 14. Filter Type 1 == Grass and Type 2 == Poison" ] }, { "cell_type": "code", "execution_count": 16, "id": "0c214af1", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.823168Z", "iopub.status.busy": "2025-09-02T18:59:27.823065Z", "iopub.status.idle": "2025-09-02T18:59:27.828493Z", "shell.execute_reply": "2025-09-02T18:59:27.828128Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
01BulbasaurGrassPoison3184549496565451False
12IvysaurGrassPoison4056062638080601False
23VenusaurGrassPoison525808283100100801False
33VenusaurMega VenusaurGrassPoison62580100123122120801False
4843OddishGrassPoison3204550557565301False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "0 1 Bulbasaur Grass Poison 318 45 49 49 \n", "1 2 Ivysaur Grass Poison 405 60 62 63 \n", "2 3 Venusaur Grass Poison 525 80 82 83 \n", "3 3 VenusaurMega Venusaur Grass Poison 625 80 100 123 \n", "48 43 Oddish Grass Poison 320 45 50 55 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "0 65 65 45 1 False \n", "1 80 80 60 1 False \n", "2 100 100 80 1 False \n", "3 122 120 80 1 False \n", "48 75 65 30 1 False " ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[(df['Type 1'] == 'Grass') & (df['Type 2'] == 'Poison')].head()" ] }, { "cell_type": "markdown", "id": "26c132d4", "metadata": {}, "source": [ "## 15. Mean HP of Legendary" ] }, { "cell_type": "code", "execution_count": 17, "id": "07e9898e", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.829732Z", "iopub.status.busy": "2025-09-02T18:59:27.829619Z", "iopub.status.idle": "2025-09-02T18:59:27.832646Z", "shell.execute_reply": "2025-09-02T18:59:27.832241Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/plain": [ "np.float64(92.73846153846154)" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[df['Legendary'] == True]['HP'].mean()" ] }, { "cell_type": "markdown", "id": "e3410f98", "metadata": {}, "source": [ "## 16. Rows with even indices" ] }, { "cell_type": "code", "execution_count": 18, "id": "93bd83be", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.834051Z", "iopub.status.busy": "2025-09-02T18:59:27.833924Z", "iopub.status.idle": "2025-09-02T18:59:27.838921Z", "shell.execute_reply": "2025-09-02T18:59:27.838509Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
01BulbasaurGrassPoison3184549496565451False
23VenusaurGrassPoison525808283100100801False
44CharmanderFireNaN3093952436050651False
66CharizardFireFlying534788478109851001False
86CharizardMega Charizard YFireFlying63478104781591151001False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "0 1 Bulbasaur Grass Poison 318 45 49 49 \n", "2 3 Venusaur Grass Poison 525 80 82 83 \n", "4 4 Charmander Fire NaN 309 39 52 43 \n", "6 6 Charizard Fire Flying 534 78 84 78 \n", "8 6 CharizardMega Charizard Y Fire Flying 634 78 104 78 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "0 65 65 45 1 False \n", "2 100 100 80 1 False \n", "4 60 50 65 1 False \n", "6 109 85 100 1 False \n", "8 159 115 100 1 False " ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "even_indices_df = df.iloc[::2]\n", "even_indices_df.head()" ] }, { "cell_type": "markdown", "id": "90002986", "metadata": {}, "source": [ "## 17. Save even indices to filtered_pokemon.csv" ] }, { "cell_type": "code", "execution_count": 19, "id": "94573f5e", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.840170Z", "iopub.status.busy": "2025-09-02T18:59:27.840060Z", "iopub.status.idle": "2025-09-02T18:59:27.850241Z", "shell.execute_reply": "2025-09-02T18:59:27.849811Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
01BulbasaurGrassPoison3184549496565451False
23VenusaurGrassPoison525808283100100801False
44CharmanderFireNaN3093952436050651False
66CharizardFireFlying534788478109851001False
86CharizardMega Charizard YFireFlying63478104781591151001False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "0 1 Bulbasaur Grass Poison 318 45 49 49 \n", "2 3 Venusaur Grass Poison 525 80 82 83 \n", "4 4 Charmander Fire NaN 309 39 52 43 \n", "6 6 Charizard Fire Flying 534 78 84 78 \n", "8 6 CharizardMega Charizard Y Fire Flying 634 78 104 78 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "0 65 65 45 1 False \n", "2 100 100 80 1 False \n", "4 60 50 65 1 False \n", "6 109 85 100 1 False \n", "8 159 115 100 1 False " ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "even_indices_df = df.iloc[::2]\n", "even_indices_df.to_csv('data/filtered_pokemon.csv', index=True)\n", "even_indices_df = pd.read_csv('data/filtered_pokemon.csv', index_col=0)\n", "even_indices_df.head()" ] }, { "cell_type": "markdown", "id": "0260bd2d", "metadata": {}, "source": [ "## 18. First 10 rows Name, Type 1, Attack" ] }, { "cell_type": "code", "execution_count": 20, "id": "4fd39662", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.851533Z", "iopub.status.busy": "2025-09-02T18:59:27.851417Z", "iopub.status.idle": "2025-09-02T18:59:27.855386Z", "shell.execute_reply": "2025-09-02T18:59:27.854971Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
NameType 1Attack
0BulbasaurGrass49
1IvysaurGrass62
2VenusaurGrass82
3VenusaurMega VenusaurGrass100
4CharmanderFire52
5CharmeleonFire64
6CharizardFire84
7CharizardMega Charizard XFire130
8CharizardMega Charizard YFire104
9SquirtleWater48
\n", "
" ], "text/plain": [ " Name Type 1 Attack\n", "0 Bulbasaur Grass 49\n", "1 Ivysaur Grass 62\n", "2 Venusaur Grass 82\n", "3 VenusaurMega Venusaur Grass 100\n", "4 Charmander Fire 52\n", "5 Charmeleon Fire 64\n", "6 Charizard Fire 84\n", "7 CharizardMega Charizard X Fire 130\n", "8 CharizardMega Charizard Y Fire 104\n", "9 Squirtle Water 48" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[['Name', 'Type 1', 'Attack']].head(10)" ] }, { "cell_type": "markdown", "id": "b4b92a28", "metadata": {}, "source": [ "## 19. Max Defense" ] }, { "cell_type": "code", "execution_count": 21, "id": "59cb441e", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.856681Z", "iopub.status.busy": "2025-09-02T18:59:27.856568Z", "iopub.status.idle": "2025-09-02T18:59:27.859195Z", "shell.execute_reply": "2025-09-02T18:59:27.858786Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/plain": [ "np.int64(230)" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df['Defense'].max()" ] }, { "cell_type": "markdown", "id": "4af9a42a", "metadata": {}, "source": [ "## 20. Rows Speed above mean" ] }, { "cell_type": "code", "execution_count": 22, "id": "87c226ad", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.860528Z", "iopub.status.busy": "2025-09-02T18:59:27.860416Z", "iopub.status.idle": "2025-09-02T18:59:27.866305Z", "shell.execute_reply": "2025-09-02T18:59:27.865916Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "mean speed: 68.2775\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
23VenusaurGrassPoison525808283100100801False
33VenusaurMega VenusaurGrassPoison62580100123122120801False
55CharmeleonFireNaN4055864588065801False
66CharizardFireFlying534788478109851001False
76CharizardMega Charizard XFireDragon63478130111130851001False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "2 3 Venusaur Grass Poison 525 80 82 83 \n", "3 3 VenusaurMega Venusaur Grass Poison 625 80 100 123 \n", "5 5 Charmeleon Fire NaN 405 58 64 58 \n", "6 6 Charizard Fire Flying 534 78 84 78 \n", "7 6 CharizardMega Charizard X Fire Dragon 634 78 130 111 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "2 100 100 80 1 False \n", "3 122 120 80 1 False \n", "5 80 65 80 1 False \n", "6 109 85 100 1 False \n", "7 130 85 100 1 False " ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mean_speed = df['Speed'].mean()\n", "new_df = df.loc[df['Speed'] > mean_speed]\n", "print('mean speed: ', mean_speed)\n", "new_df.head()" ] }, { "cell_type": "markdown", "id": "2cd6a072", "metadata": {}, "source": [ "## 21. First 3 rows Name and Attack" ] }, { "cell_type": "code", "execution_count": 23, "id": "1994db42", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.867631Z", "iopub.status.busy": "2025-09-02T18:59:27.867520Z", "iopub.status.idle": "2025-09-02T18:59:27.871104Z", "shell.execute_reply": "2025-09-02T18:59:27.870701Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
NameAttack
0Bulbasaur49
1Ivysaur62
2Venusaur82
\n", "
" ], "text/plain": [ " Name Attack\n", "0 Bulbasaur 49\n", "1 Ivysaur 62\n", "2 Venusaur 82" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[['Name', 'Attack']].iloc[:3]" ] }, { "cell_type": "markdown", "id": "879c9ee3", "metadata": {}, "source": [ "## 22. Count per Type 1" ] }, { "cell_type": "code", "execution_count": 24, "id": "b193160f", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.872405Z", "iopub.status.busy": "2025-09-02T18:59:27.872294Z", "iopub.status.idle": "2025-09-02T18:59:27.875749Z", "shell.execute_reply": "2025-09-02T18:59:27.875375Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/plain": [ "Type 1\n", "Bug 69\n", "Dark 31\n", "Dragon 32\n", "Electric 44\n", "Fairy 17\n", "Fighting 27\n", "Fire 52\n", "Flying 4\n", "Ghost 32\n", "Grass 70\n", "Ground 32\n", "Ice 24\n", "Normal 98\n", "Poison 28\n", "Psychic 57\n", "Rock 44\n", "Steel 27\n", "Water 112\n", "Name: #, dtype: int64" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.groupby(['Type 1'])['#'].count().sort_index()" ] }, { "cell_type": "markdown", "id": "764f75f2", "metadata": {}, "source": [ "## 23. Rows Generation 3 or 5" ] }, { "cell_type": "code", "execution_count": 25, "id": "fcf4cbda", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.877087Z", "iopub.status.busy": "2025-09-02T18:59:27.876977Z", "iopub.status.idle": "2025-09-02T18:59:27.882250Z", "shell.execute_reply": "2025-09-02T18:59:27.881877Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
272252TreeckoGrassNaN3104045356555703False
273253GrovyleGrassNaN4055065458565953False
274254SceptileGrassNaN530708565105851203False
275254SceptileMega SceptileGrassDragon6307011075145851453False
276255TorchicFireNaN3104560407050453False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "272 252 Treecko Grass NaN 310 40 45 35 \n", "273 253 Grovyle Grass NaN 405 50 65 45 \n", "274 254 Sceptile Grass NaN 530 70 85 65 \n", "275 254 SceptileMega Sceptile Grass Dragon 630 70 110 75 \n", "276 255 Torchic Fire NaN 310 45 60 40 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "272 65 55 70 3 False \n", "273 85 65 95 3 False \n", "274 105 85 120 3 False \n", "275 145 85 145 3 False \n", "276 70 50 45 3 False " ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[(df['Generation'] == 3) | (df['Generation'] == 5)].head()" ] }, { "cell_type": "markdown", "id": "ef9a7aca", "metadata": {}, "source": [ "## 24. Replace Fire with Flame in Type 1" ] }, { "cell_type": "code", "execution_count": 26, "id": "3ee5c44d", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.883394Z", "iopub.status.busy": "2025-09-02T18:59:27.883284Z", "iopub.status.idle": "2025-09-02T18:59:27.888613Z", "shell.execute_reply": "2025-09-02T18:59:27.888187Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
01BulbasaurGrassPoison3184549496565451False
12IvysaurGrassPoison4056062638080601False
23VenusaurGrassPoison525808283100100801False
33VenusaurMega VenusaurGrassPoison62580100123122120801False
44CharmanderFlameNaN3093952436050651False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "0 1 Bulbasaur Grass Poison 318 45 49 49 \n", "1 2 Ivysaur Grass Poison 405 60 62 63 \n", "2 3 Venusaur Grass Poison 525 80 82 83 \n", "3 3 VenusaurMega Venusaur Grass Poison 625 80 100 123 \n", "4 4 Charmander Flame NaN 309 39 52 43 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "0 65 65 45 1 False \n", "1 80 80 60 1 False \n", "2 100 100 80 1 False \n", "3 122 120 80 1 False \n", "4 60 50 65 1 False " ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_copy = df.copy()\n", "df_copy['Type 1'] = df_copy['Type 1'].str.replace('Fire', 'Flame')\n", "df_copy.head()" ] }, { "cell_type": "markdown", "id": "086e2db1", "metadata": {}, "source": [ "## 25. Rows Name startswith P" ] }, { "cell_type": "code", "execution_count": 27, "id": "cbaf7ac5", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.889823Z", "iopub.status.busy": "2025-09-02T18:59:27.889715Z", "iopub.status.idle": "2025-09-02T18:59:27.894897Z", "shell.execute_reply": "2025-09-02T18:59:27.894496Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
2016PidgeyNormalFlying2514045403535561False
2117PidgeottoNormalFlying3496360555050711False
2218PidgeotNormalFlying47983807570701011False
2318PidgeotMega PidgeotNormalFlying579838080135801211False
3025PikachuElectricNaN3203555405050901False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "20 16 Pidgey Normal Flying 251 40 45 40 \n", "21 17 Pidgeotto Normal Flying 349 63 60 55 \n", "22 18 Pidgeot Normal Flying 479 83 80 75 \n", "23 18 PidgeotMega Pidgeot Normal Flying 579 83 80 80 \n", "30 25 Pikachu Electric NaN 320 35 55 40 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "20 35 35 56 1 False \n", "21 50 50 71 1 False \n", "22 70 70 101 1 False \n", "23 135 80 121 1 False \n", "30 50 50 90 1 False " ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[df['Name'].str.startswith('P')].head()" ] }, { "cell_type": "markdown", "id": "cfce5693", "metadata": {}, "source": [ "## 26. Mean Attack per Type 1" ] }, { "cell_type": "code", "execution_count": 28, "id": "524b0ff9", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.895969Z", "iopub.status.busy": "2025-09-02T18:59:27.895858Z", "iopub.status.idle": "2025-09-02T18:59:27.900035Z", "shell.execute_reply": "2025-09-02T18:59:27.899662Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/plain": [ "Type 1\n", "Bug 70.971014\n", "Dark 88.387097\n", "Dragon 112.125000\n", "Electric 69.090909\n", "Fairy 61.529412\n", "Fighting 96.777778\n", "Fire 84.769231\n", "Flying 78.750000\n", "Ghost 73.781250\n", "Grass 73.214286\n", "Ground 95.750000\n", "Ice 72.750000\n", "Normal 73.469388\n", "Poison 74.678571\n", "Psychic 71.456140\n", "Rock 92.863636\n", "Steel 92.703704\n", "Water 74.151786\n", "Name: Attack, dtype: float64" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.groupby('Type 1')['Attack'].mean().sort_index()" ] }, { "cell_type": "markdown", "id": "5655f539", "metadata": {}, "source": [ "## 27. Sort by Type 1 asc, Attack desc" ] }, { "cell_type": "code", "execution_count": 29, "id": "6ea3d2cd", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.901238Z", "iopub.status.busy": "2025-09-02T18:59:27.901127Z", "iopub.status.idle": "2025-09-02T18:59:27.906773Z", "shell.execute_reply": "2025-09-02T18:59:27.906397Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
232214HeracrossMega HeracrossBugFighting6008018511540105752False
137127PinsirMega PinsirBugFlying6006515512065901051False
1915BeedrillMega BeedrillBugPoison495651504015801451False
229212ScizorMega ScizorBugSteel6007015014065100752False
650589EscavalierBugSteel4957013510560105205False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack \\\n", "232 214 HeracrossMega Heracross Bug Fighting 600 80 185 \n", "137 127 PinsirMega Pinsir Bug Flying 600 65 155 \n", "19 15 BeedrillMega Beedrill Bug Poison 495 65 150 \n", "229 212 ScizorMega Scizor Bug Steel 600 70 150 \n", "650 589 Escavalier Bug Steel 495 70 135 \n", "\n", " Defense Sp. Atk Sp. Def Speed Generation Legendary \n", "232 115 40 105 75 2 False \n", "137 120 65 90 105 1 False \n", "19 40 15 80 145 1 False \n", "229 140 65 100 75 2 False \n", "650 105 60 105 20 5 False " ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.sort_values(['Type 1', 'Attack'], ascending=[1, 0]).head()" ] }, { "cell_type": "markdown", "id": "b4044848", "metadata": {}, "source": [ "## 28. Mean Defense per Type 1" ] }, { "cell_type": "code", "execution_count": 30, "id": "199b1315", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.907941Z", "iopub.status.busy": "2025-09-02T18:59:27.907837Z", "iopub.status.idle": "2025-09-02T18:59:27.911499Z", "shell.execute_reply": "2025-09-02T18:59:27.911125Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/plain": [ "Type 1\n", "Bug 70.724638\n", "Dark 70.225806\n", "Dragon 86.375000\n", "Electric 66.295455\n", "Fairy 65.705882\n", "Fighting 65.925926\n", "Fire 67.769231\n", "Flying 66.250000\n", "Ghost 81.187500\n", "Grass 70.800000\n", "Ground 84.843750\n", "Ice 71.416667\n", "Normal 59.846939\n", "Poison 68.821429\n", "Psychic 67.684211\n", "Rock 100.795455\n", "Steel 126.370370\n", "Water 72.946429\n", "Name: Defense, dtype: float64" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.groupby('Type 1')['Defense'].mean().sort_index()" ] }, { "cell_type": "markdown", "id": "f03114cd", "metadata": {}, "source": [ "## 29. Legendary with Attack > 100" ] }, { "cell_type": "code", "execution_count": 31, "id": "26d0d126", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.912967Z", "iopub.status.busy": "2025-09-02T18:59:27.912859Z", "iopub.status.idle": "2025-09-02T18:59:27.918207Z", "shell.execute_reply": "2025-09-02T18:59:27.917805Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
162150MewtwoPsychicNaN68010611090154901301True
163150MewtwoMega Mewtwo XPsychicFighting7801061901001541001301True
164150MewtwoMega Mewtwo YPsychicNaN780106150701941201401True
263244EnteiFireNaN5801151158590751002True
270250Ho-ohFireFlying68010613090110154902True
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "162 150 Mewtwo Psychic NaN 680 106 110 90 \n", "163 150 MewtwoMega Mewtwo X Psychic Fighting 780 106 190 100 \n", "164 150 MewtwoMega Mewtwo Y Psychic NaN 780 106 150 70 \n", "263 244 Entei Fire NaN 580 115 115 85 \n", "270 250 Ho-oh Fire Flying 680 106 130 90 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "162 154 90 130 1 True \n", "163 154 100 130 1 True \n", "164 194 120 140 1 True \n", "263 90 75 100 2 True \n", "270 110 154 90 2 True " ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[(df['Legendary'] == True) & (df['Attack'] > 100)].head()" ] }, { "cell_type": "markdown", "id": "041c63c2", "metadata": {}, "source": [ "## 30. New DataFrame Name and Total renamed Overall" ] }, { "cell_type": "code", "execution_count": 32, "id": "1a4711ee", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.919766Z", "iopub.status.busy": "2025-09-02T18:59:27.919639Z", "iopub.status.idle": "2025-09-02T18:59:27.925033Z", "shell.execute_reply": "2025-09-02T18:59:27.924389Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
NameOverall
0Bulbasaur318
1Ivysaur405
2Venusaur525
3VenusaurMega Venusaur625
4Charmander309
\n", "
" ], "text/plain": [ " Name Overall\n", "0 Bulbasaur 318\n", "1 Ivysaur 405\n", "2 Venusaur 525\n", "3 VenusaurMega Venusaur 625\n", "4 Charmander 309" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "new_df = df[['Name', 'Total']].rename(columns={'Total': 'Overall'})\n", "new_df.head()" ] }, { "cell_type": "markdown", "id": "e91c37c1", "metadata": {}, "source": [ "## 31. Filter Type 1 == Water and Attack >= 80" ] }, { "cell_type": "code", "execution_count": 33, "id": "da292ffb", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.926458Z", "iopub.status.busy": "2025-09-02T18:59:27.926344Z", "iopub.status.idle": "2025-09-02T18:59:27.931867Z", "shell.execute_reply": "2025-09-02T18:59:27.931503Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
119BlastoiseWaterNaN530798310085105781False
129BlastoiseMega BlastoiseWaterNaN63079103120135115781False
6055GolduckWaterNaN5008082789580851False
6762PoliwrathWaterFighting5109095957090701False
9891CloysterWaterIce52550951808545701False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "11 9 Blastoise Water NaN 530 79 83 100 \n", "12 9 BlastoiseMega Blastoise Water NaN 630 79 103 120 \n", "60 55 Golduck Water NaN 500 80 82 78 \n", "67 62 Poliwrath Water Fighting 510 90 95 95 \n", "98 91 Cloyster Water Ice 525 50 95 180 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "11 85 105 78 1 False \n", "12 135 115 78 1 False \n", "60 95 80 85 1 False \n", "67 70 90 70 1 False \n", "98 85 45 70 1 False " ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[(df['Type 1'] == 'Water') & (df['Attack'] >= 80)].head()" ] }, { "cell_type": "markdown", "id": "81bd002b", "metadata": {}, "source": [ "## 32. Generation 4 Name and Defense" ] }, { "cell_type": "code", "execution_count": 34, "id": "b2b2cfc5", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.933205Z", "iopub.status.busy": "2025-09-02T18:59:27.933092Z", "iopub.status.idle": "2025-09-02T18:59:27.937350Z", "shell.execute_reply": "2025-09-02T18:59:27.936994Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
NameDefense
432Turtwig64
433Grotle85
434Torterra105
435Chimchar44
436Monferno52
\n", "
" ], "text/plain": [ " Name Defense\n", "432 Turtwig 64\n", "433 Grotle 85\n", "434 Torterra 105\n", "435 Chimchar 44\n", "436 Monferno 52" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[df['Generation'] == 4][['Name', 'Defense']].head()" ] }, { "cell_type": "markdown", "id": "b90e2efb", "metadata": {}, "source": [ "## 33. Mean Total per (Type 1, Type 2)" ] }, { "cell_type": "code", "execution_count": 35, "id": "aae709eb", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.938722Z", "iopub.status.busy": "2025-09-02T18:59:27.938613Z", "iopub.status.idle": "2025-09-02T18:59:27.943084Z", "shell.execute_reply": "2025-09-02T18:59:27.942710Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/plain": [ "Type 1 Type 2 \n", "Bug Electric 395.500000\n", " Fighting 550.000000\n", " Fire 455.000000\n", " Flying 419.500000\n", " Ghost 236.000000\n", " Grass 384.000000\n", " Ground 345.000000\n", " Poison 347.916667\n", " Rock 435.000000\n", " Steel 509.714286\n", "Name: Total, dtype: float64" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.groupby(['Type 1', 'Type 2'])['Total'].mean().head(10)" ] }, { "cell_type": "markdown", "id": "86e698d7", "metadata": {}, "source": [ "## 34. Filter Total between 400 and 500" ] }, { "cell_type": "code", "execution_count": 36, "id": "a2736c5c", "metadata": { "execution": { "iopub.execute_input": "2025-09-02T18:59:27.944404Z", "iopub.status.busy": "2025-09-02T18:59:27.944295Z", "iopub.status.idle": "2025-09-02T18:59:27.949491Z", "shell.execute_reply": "2025-09-02T18:59:27.949109Z" }, "tags": [ "hide-output", "scroll-output" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
#NameType 1Type 2TotalHPAttackDefenseSp. AtkSp. DefSpeedGenerationLegendary
12IvysaurGrassPoison4056062638080601False
55CharmeleonFireNaN4055864588065801False
108WartortleWaterNaN4055963806580581False
1915BeedrillMega BeedrillBugPoison495651504015801451False
2218PidgeotNormalFlying47983807570701011False
\n", "
" ], "text/plain": [ " # Name Type 1 Type 2 Total HP Attack Defense \\\n", "1 2 Ivysaur Grass Poison 405 60 62 63 \n", "5 5 Charmeleon Fire NaN 405 58 64 58 \n", "10 8 Wartortle Water NaN 405 59 63 80 \n", "19 15 BeedrillMega Beedrill Bug Poison 495 65 150 40 \n", "22 18 Pidgeot Normal Flying 479 83 80 75 \n", "\n", " Sp. Atk Sp. Def Speed Generation Legendary \n", "1 80 80 60 1 False \n", "5 80 65 80 1 False \n", "10 65 80 58 1 False \n", "19 15 80 145 1 False \n", "22 70 70 101 1 False " ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[(df['Total'] >= 400) & (df['Total'] <= 500)].head()" ] } ], "metadata": { "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" } }, "nbformat": 4, "nbformat_minor": 5 }