import pandas as pd
#reading csv
df = pd.read_csv('pokemon_data.csv')
print(df.head())
#reading excel
#df_xlsx = pd.read_excel('pokemon_data.xlsx')
#print(df_xlsx.head())
#reading txt
#df_txt = pd.read_csv('pokemon_data.txt', delimiter = '\t')
#print(df_txt.head())
# Name Type 1 Type 2 HP Attack Defense Sp. Atk \ 0 1 Bulbasaur Grass Poison 45 49 49 65 1 2 Ivysaur Grass Poison 60 62 63 80 2 3 Venusaur Grass Poison 80 82 83 100 3 3 VenusaurMega Venusaur Grass Poison 80 100 123 122 4 4 Charmander Fire NaN 39 52 43 60 Sp. Def Speed Generation Legendary 0 65 45 1 False 1 80 60 1 False 2 100 80 1 False 3 120 80 1 False 4 50 65 1 False
#Read Headers
#print(df.columns)
#or
df.columns
Index(['#', 'Name', 'Type 1', 'Type 2', 'HP', 'Attack', 'Defense', 'Sp. Atk', 'Sp. Def', 'Speed', 'Generation', 'Legendary'], dtype='object')
#Read each Column
print(df[['Name', 'Type 1', 'HP']][0:10])
Name Type 1 HP 0 Bulbasaur Grass 45 1 Ivysaur Grass 60 2 Venusaur Grass 80 3 VenusaurMega Venusaur Grass 80 4 Charmander Fire 39 5 Charmeleon Fire 58 6 Charizard Fire 78 7 CharizardMega Charizard X Fire 78 8 CharizardMega Charizard Y Fire 78 9 Squirtle Water 44
#Read each Row
print(df.iloc[0:4])
# Name Type 1 Type 2 HP Attack Defense Sp. Atk \ 0 1 Bulbasaur Grass Poison 45 49 49 65 1 2 Ivysaur Grass Poison 60 62 63 80 2 3 Venusaur Grass Poison 80 82 83 100 3 3 VenusaurMega Venusaur Grass Poison 80 100 123 122 Sp. Def Speed Generation Legendary 0 65 45 1 False 1 80 60 1 False 2 100 80 1 False 3 120 80 1 False
#For getting a list of a column
for index, row in df.iterrows():
print(index, row['Name'])
0 Bulbasaur 1 Ivysaur 2 Venusaur 3 VenusaurMega Venusaur 4 Charmander 5 Charmeleon 6 Charizard 7 CharizardMega Charizard X 8 CharizardMega Charizard Y 9 Squirtle 10 Wartortle 11 Blastoise 12 BlastoiseMega Blastoise 13 Caterpie 14 Metapod 15 Butterfree 16 Weedle 17 Kakuna 18 Beedrill 19 BeedrillMega Beedrill 20 Pidgey 21 Pidgeotto 22 Pidgeot 23 PidgeotMega Pidgeot 24 Rattata 25 Raticate 26 Spearow 27 Fearow 28 Ekans 29 Arbok 30 Pikachu 31 Raichu 32 Sandshrew 33 Sandslash 34 Nidoran (Female) 35 Nidorina 36 Nidoqueen 37 Nidoran (Male) 38 Nidorino 39 Nidoking 40 Clefairy 41 Clefable 42 Vulpix 43 Ninetales 44 Jigglypuff 45 Wigglytuff 46 Zubat 47 Golbat 48 Oddish 49 Gloom 50 Vileplume 51 Paras 52 Parasect 53 Venonat 54 Venomoth 55 Diglett 56 Dugtrio 57 Meowth 58 Persian 59 Psyduck 60 Golduck 61 Mankey 62 Primeape 63 Growlithe 64 Arcanine 65 Poliwag 66 Poliwhirl 67 Poliwrath 68 Abra 69 Kadabra 70 Alakazam 71 AlakazamMega Alakazam 72 Machop 73 Machoke 74 Machamp 75 Bellsprout 76 Weepinbell 77 Victreebel 78 Tentacool 79 Tentacruel 80 Geodude 81 Graveler 82 Golem 83 Ponyta 84 Rapidash 85 Slowpoke 86 Slowbro 87 SlowbroMega Slowbro 88 Magnemite 89 Magneton 90 Farfetch'd 91 Doduo 92 Dodrio 93 Seel 94 Dewgong 95 Grimer 96 Muk 97 Shellder 98 Cloyster 99 Gastly 100 Haunter 101 Gengar 102 GengarMega Gengar 103 Onix 104 Drowzee 105 Hypno 106 Krabby 107 Kingler 108 Voltorb 109 Electrode 110 Exeggcute 111 Exeggutor 112 Cubone 113 Marowak 114 Hitmonlee 115 Hitmonchan 116 Lickitung 117 Koffing 118 Weezing 119 Rhyhorn 120 Rhydon 121 Chansey 122 Tangela 123 Kangaskhan 124 KangaskhanMega Kangaskhan 125 Horsea 126 Seadra 127 Goldeen 128 Seaking 129 Staryu 130 Starmie 131 Mr. Mime 132 Scyther 133 Jynx 134 Electabuzz 135 Magmar 136 Pinsir 137 PinsirMega Pinsir 138 Tauros 139 Magikarp 140 Gyarados 141 GyaradosMega Gyarados 142 Lapras 143 Ditto 144 Eevee 145 Vaporeon 146 Jolteon 147 Flareon 148 Porygon 149 Omanyte 150 Omastar 151 Kabuto 152 Kabutops 153 Aerodactyl 154 AerodactylMega Aerodactyl 155 Snorlax 156 Articuno 157 Zapdos 158 Moltres 159 Dratini 160 Dragonair 161 Dragonite 162 Mewtwo 163 MewtwoMega Mewtwo X 164 MewtwoMega Mewtwo Y 165 Mew 166 Chikorita 167 Bayleef 168 Meganium 169 Cyndaquil 170 Quilava 171 Typhlosion 172 Totodile 173 Croconaw 174 Feraligatr 175 Sentret 176 Furret 177 Hoothoot 178 Noctowl 179 Ledyba 180 Ledian 181 Spinarak 182 Ariados 183 Crobat 184 Chinchou 185 Lanturn 186 Pichu 187 Cleffa 188 Igglybuff 189 Togepi 190 Togetic 191 Natu 192 Xatu 193 Mareep 194 Flaaffy 195 Ampharos 196 AmpharosMega Ampharos 197 Bellossom 198 Marill 199 Azumarill 200 Sudowoodo 201 Politoed 202 Hoppip 203 Skiploom 204 Jumpluff 205 Aipom 206 Sunkern 207 Sunflora 208 Yanma 209 Wooper 210 Quagsire 211 Espeon 212 Umbreon 213 Murkrow 214 Slowking 215 Misdreavus 216 Unown 217 Wobbuffet 218 Girafarig 219 Pineco 220 Forretress 221 Dunsparce 222 Gligar 223 Steelix 224 SteelixMega Steelix 225 Snubbull 226 Granbull 227 Qwilfish 228 Scizor 229 ScizorMega Scizor 230 Shuckle 231 Heracross 232 HeracrossMega Heracross 233 Sneasel 234 Teddiursa 235 Ursaring 236 Slugma 237 Magcargo 238 Swinub 239 Piloswine 240 Corsola 241 Remoraid 242 Octillery 243 Delibird 244 Mantine 245 Skarmory 246 Houndour 247 Houndoom 248 HoundoomMega Houndoom 249 Kingdra 250 Phanpy 251 Donphan 252 Porygon2 253 Stantler 254 Smeargle 255 Tyrogue 256 Hitmontop 257 Smoochum 258 Elekid 259 Magby 260 Miltank 261 Blissey 262 Raikou 263 Entei 264 Suicune 265 Larvitar 266 Pupitar 267 Tyranitar 268 TyranitarMega Tyranitar 269 Lugia 270 Ho-oh 271 Celebi 272 Treecko 273 Grovyle 274 Sceptile 275 SceptileMega Sceptile 276 Torchic 277 Combusken 278 Blaziken 279 BlazikenMega Blaziken 280 Mudkip 281 Marshtomp 282 Swampert 283 SwampertMega Swampert 284 Poochyena 285 Mightyena 286 Zigzagoon 287 Linoone 288 Wurmple 289 Silcoon 290 Beautifly 291 Cascoon 292 Dustox 293 Lotad 294 Lombre 295 Ludicolo 296 Seedot 297 Nuzleaf 298 Shiftry 299 Taillow 300 Swellow 301 Wingull 302 Pelipper 303 Ralts 304 Kirlia 305 Gardevoir 306 GardevoirMega Gardevoir 307 Surskit 308 Masquerain 309 Shroomish 310 Breloom 311 Slakoth 312 Vigoroth 313 Slaking 314 Nincada 315 Ninjask 316 Shedinja 317 Whismur 318 Loudred 319 Exploud 320 Makuhita 321 Hariyama 322 Azurill 323 Nosepass 324 Skitty 325 Delcatty 326 Sableye 327 SableyeMega Sableye 328 Mawile 329 MawileMega Mawile 330 Aron 331 Lairon 332 Aggron 333 AggronMega Aggron 334 Meditite 335 Medicham 336 MedichamMega Medicham 337 Electrike 338 Manectric 339 ManectricMega Manectric 340 Plusle 341 Minun 342 Volbeat 343 Illumise 344 Roselia 345 Gulpin 346 Swalot 347 Carvanha 348 Sharpedo 349 SharpedoMega Sharpedo 350 Wailmer 351 Wailord 352 Numel 353 Camerupt 354 CameruptMega Camerupt 355 Torkoal 356 Spoink 357 Grumpig 358 Spinda 359 Trapinch 360 Vibrava 361 Flygon 362 Cacnea 363 Cacturne 364 Swablu 365 Altaria 366 AltariaMega Altaria 367 Zangoose 368 Seviper 369 Lunatone 370 Solrock 371 Barboach 372 Whiscash 373 Corphish 374 Crawdaunt 375 Baltoy 376 Claydol 377 Lileep 378 Cradily 379 Anorith 380 Armaldo 381 Feebas 382 Milotic 383 Castform 384 Kecleon 385 Shuppet 386 Banette 387 BanetteMega Banette 388 Duskull 389 Dusclops 390 Tropius 391 Chimecho 392 Absol 393 AbsolMega Absol 394 Wynaut 395 Snorunt 396 Glalie 397 GlalieMega Glalie 398 Spheal 399 Sealeo 400 Walrein 401 Clamperl 402 Huntail 403 Gorebyss 404 Relicanth 405 Luvdisc 406 Bagon 407 Shelgon 408 Salamence 409 SalamenceMega Salamence 410 Beldum 411 Metang 412 Metagross 413 MetagrossMega Metagross 414 Regirock 415 Regice 416 Registeel 417 Latias 418 LatiasMega Latias 419 Latios 420 LatiosMega Latios 421 Kyogre 422 KyogrePrimal Kyogre 423 Groudon 424 GroudonPrimal Groudon 425 Rayquaza 426 RayquazaMega Rayquaza 427 Jirachi 428 DeoxysNormal Forme 429 DeoxysAttack Forme 430 DeoxysDefense Forme 431 DeoxysSpeed Forme 432 Turtwig 433 Grotle 434 Torterra 435 Chimchar 436 Monferno 437 Infernape 438 Piplup 439 Prinplup 440 Empoleon 441 Starly 442 Staravia 443 Staraptor 444 Bidoof 445 Bibarel 446 Kricketot 447 Kricketune 448 Shinx 449 Luxio 450 Luxray 451 Budew 452 Roserade 453 Cranidos 454 Rampardos 455 Shieldon 456 Bastiodon 457 Burmy 458 WormadamPlant Cloak 459 WormadamSandy Cloak 460 WormadamTrash Cloak 461 Mothim 462 Combee 463 Vespiquen 464 Pachirisu 465 Buizel 466 Floatzel 467 Cherubi 468 Cherrim 469 Shellos 470 Gastrodon 471 Ambipom 472 Drifloon 473 Drifblim 474 Buneary 475 Lopunny 476 LopunnyMega Lopunny 477 Mismagius 478 Honchkrow 479 Glameow 480 Purugly 481 Chingling 482 Stunky 483 Skuntank 484 Bronzor 485 Bronzong 486 Bonsly 487 Mime Jr. 488 Happiny 489 Chatot 490 Spiritomb 491 Gible 492 Gabite 493 Garchomp 494 GarchompMega Garchomp 495 Munchlax 496 Riolu 497 Lucario 498 LucarioMega Lucario 499 Hippopotas 500 Hippowdon 501 Skorupi 502 Drapion 503 Croagunk 504 Toxicroak 505 Carnivine 506 Finneon 507 Lumineon 508 Mantyke 509 Snover 510 Abomasnow 511 AbomasnowMega Abomasnow 512 Weavile 513 Magnezone 514 Lickilicky 515 Rhyperior 516 Tangrowth 517 Electivire 518 Magmortar 519 Togekiss 520 Yanmega 521 Leafeon 522 Glaceon 523 Gliscor 524 Mamoswine 525 Porygon-Z 526 Gallade 527 GalladeMega Gallade 528 Probopass 529 Dusknoir 530 Froslass 531 Rotom 532 RotomHeat Rotom 533 RotomWash Rotom 534 RotomFrost Rotom 535 RotomFan Rotom 536 RotomMow Rotom 537 Uxie 538 Mesprit 539 Azelf 540 Dialga 541 Palkia 542 Heatran 543 Regigigas 544 GiratinaAltered Forme 545 GiratinaOrigin Forme 546 Cresselia 547 Phione 548 Manaphy 549 Darkrai 550 ShayminLand Forme 551 ShayminSky Forme 552 Arceus 553 Victini 554 Snivy 555 Servine 556 Serperior 557 Tepig 558 Pignite 559 Emboar 560 Oshawott 561 Dewott 562 Samurott 563 Patrat 564 Watchog 565 Lillipup 566 Herdier 567 Stoutland 568 Purrloin 569 Liepard 570 Pansage 571 Simisage 572 Pansear 573 Simisear 574 Panpour 575 Simipour 576 Munna 577 Musharna 578 Pidove 579 Tranquill 580 Unfezant 581 Blitzle 582 Zebstrika 583 Roggenrola 584 Boldore 585 Gigalith 586 Woobat 587 Swoobat 588 Drilbur 589 Excadrill 590 Audino 591 AudinoMega Audino 592 Timburr 593 Gurdurr 594 Conkeldurr 595 Tympole 596 Palpitoad 597 Seismitoad 598 Throh 599 Sawk 600 Sewaddle 601 Swadloon 602 Leavanny 603 Venipede 604 Whirlipede 605 Scolipede 606 Cottonee 607 Whimsicott 608 Petilil 609 Lilligant 610 Basculin 611 Sandile 612 Krokorok 613 Krookodile 614 Darumaka 615 DarmanitanStandard Mode 616 DarmanitanZen Mode 617 Maractus 618 Dwebble 619 Crustle 620 Scraggy 621 Scrafty 622 Sigilyph 623 Yamask 624 Cofagrigus 625 Tirtouga 626 Carracosta 627 Archen 628 Archeops 629 Trubbish 630 Garbodor 631 Zorua 632 Zoroark 633 Minccino 634 Cinccino 635 Gothita 636 Gothorita 637 Gothitelle 638 Solosis 639 Duosion 640 Reuniclus 641 Ducklett 642 Swanna 643 Vanillite 644 Vanillish 645 Vanilluxe 646 Deerling 647 Sawsbuck 648 Emolga 649 Karrablast 650 Escavalier 651 Foongus 652 Amoonguss 653 Frillish 654 Jellicent 655 Alomomola 656 Joltik 657 Galvantula 658 Ferroseed 659 Ferrothorn 660 Klink 661 Klang 662 Klinklang 663 Tynamo 664 Eelektrik 665 Eelektross 666 Elgyem 667 Beheeyem 668 Litwick 669 Lampent 670 Chandelure 671 Axew 672 Fraxure 673 Haxorus 674 Cubchoo 675 Beartic 676 Cryogonal 677 Shelmet 678 Accelgor 679 Stunfisk 680 Mienfoo 681 Mienshao 682 Druddigon 683 Golett 684 Golurk 685 Pawniard 686 Bisharp 687 Bouffalant 688 Rufflet 689 Braviary 690 Vullaby 691 Mandibuzz 692 Heatmor 693 Durant 694 Deino 695 Zweilous 696 Hydreigon 697 Larvesta 698 Volcarona 699 Cobalion 700 Terrakion 701 Virizion 702 TornadusIncarnate Forme 703 TornadusTherian Forme 704 ThundurusIncarnate Forme 705 ThundurusTherian Forme 706 Reshiram 707 Zekrom 708 LandorusIncarnate Forme 709 LandorusTherian Forme 710 Kyurem 711 KyuremBlack Kyurem 712 KyuremWhite Kyurem 713 KeldeoOrdinary Forme 714 KeldeoResolute Forme 715 MeloettaAria Forme 716 MeloettaPirouette Forme 717 Genesect 718 Chespin 719 Quilladin 720 Chesnaught 721 Fennekin 722 Braixen 723 Delphox 724 Froakie 725 Frogadier 726 Greninja 727 Bunnelby 728 Diggersby 729 Fletchling 730 Fletchinder 731 Talonflame 732 Scatterbug 733 Spewpa 734 Vivillon 735 Litleo 736 Pyroar 737 Flabébé 738 Floette 739 Florges 740 Skiddo 741 Gogoat 742 Pancham 743 Pangoro 744 Furfrou 745 Espurr 746 MeowsticMale 747 MeowsticFemale 748 Honedge 749 Doublade 750 AegislashBlade Forme 751 AegislashShield Forme 752 Spritzee 753 Aromatisse 754 Swirlix 755 Slurpuff 756 Inkay 757 Malamar 758 Binacle 759 Barbaracle 760 Skrelp 761 Dragalge 762 Clauncher 763 Clawitzer 764 Helioptile 765 Heliolisk 766 Tyrunt 767 Tyrantrum 768 Amaura 769 Aurorus 770 Sylveon 771 Hawlucha 772 Dedenne 773 Carbink 774 Goomy 775 Sliggoo 776 Goodra 777 Klefki 778 Phantump 779 Trevenant 780 PumpkabooAverage Size 781 PumpkabooSmall Size 782 PumpkabooLarge Size 783 PumpkabooSuper Size 784 GourgeistAverage Size 785 GourgeistSmall Size 786 GourgeistLarge Size 787 GourgeistSuper Size 788 Bergmite 789 Avalugg 790 Noibat 791 Noivern 792 Xerneas 793 Yveltal 794 Zygarde50% Forme 795 Diancie 796 DiancieMega Diancie 797 HoopaHoopa Confined 798 HoopaHoopa Unbound 799 Volcanion
#Read a specific location (R, C)
print(df.iloc[2, 1])
Venusaur
df.loc[df['Type 1'] == 'Fire'][0:10]
# | Name | Type 1 | Type 2 | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Generation | Legendary | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
4 | 4 | Charmander | Fire | NaN | 39 | 52 | 43 | 60 | 50 | 65 | 1 | False |
5 | 5 | Charmeleon | Fire | NaN | 58 | 64 | 58 | 80 | 65 | 80 | 1 | False |
6 | 6 | Charizard | Fire | Flying | 78 | 84 | 78 | 109 | 85 | 100 | 1 | False |
7 | 6 | CharizardMega Charizard X | Fire | Dragon | 78 | 130 | 111 | 130 | 85 | 100 | 1 | False |
8 | 6 | CharizardMega Charizard Y | Fire | Flying | 78 | 104 | 78 | 159 | 115 | 100 | 1 | False |
42 | 37 | Vulpix | Fire | NaN | 38 | 41 | 40 | 50 | 65 | 65 | 1 | False |
43 | 38 | Ninetales | Fire | NaN | 73 | 76 | 75 | 81 | 100 | 100 | 1 | False |
63 | 58 | Growlithe | Fire | NaN | 55 | 70 | 45 | 70 | 50 | 60 | 1 | False |
64 | 59 | Arcanine | Fire | NaN | 90 | 110 | 80 | 100 | 80 | 95 | 1 | False |
83 | 77 | Ponyta | Fire | NaN | 50 | 85 | 55 | 65 | 65 | 90 | 1 | False |
df.loc[df['Type 1'] == 'Grass'][0:10]
# | Name | Type 1 | Type 2 | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Generation | Legendary | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Bulbasaur | Grass | Poison | 45 | 49 | 49 | 65 | 65 | 45 | 1 | False |
1 | 2 | Ivysaur | Grass | Poison | 60 | 62 | 63 | 80 | 80 | 60 | 1 | False |
2 | 3 | Venusaur | Grass | Poison | 80 | 82 | 83 | 100 | 100 | 80 | 1 | False |
3 | 3 | VenusaurMega Venusaur | Grass | Poison | 80 | 100 | 123 | 122 | 120 | 80 | 1 | False |
48 | 43 | Oddish | Grass | Poison | 45 | 50 | 55 | 75 | 65 | 30 | 1 | False |
49 | 44 | Gloom | Grass | Poison | 60 | 65 | 70 | 85 | 75 | 40 | 1 | False |
50 | 45 | Vileplume | Grass | Poison | 75 | 80 | 85 | 110 | 90 | 50 | 1 | False |
75 | 69 | Bellsprout | Grass | Poison | 50 | 75 | 35 | 70 | 30 | 40 | 1 | False |
76 | 70 | Weepinbell | Grass | Poison | 65 | 90 | 50 | 85 | 45 | 55 | 1 | False |
77 | 71 | Victreebel | Grass | Poison | 80 | 105 | 65 | 100 | 70 | 70 | 1 | False |
df.describe()
# | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Generation | |
---|---|---|---|---|---|---|---|---|
count | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.00000 |
mean | 362.813750 | 69.258750 | 79.001250 | 73.842500 | 72.820000 | 71.902500 | 68.277500 | 3.32375 |
std | 208.343798 | 25.534669 | 32.457366 | 31.183501 | 32.722294 | 27.828916 | 29.060474 | 1.66129 |
min | 1.000000 | 1.000000 | 5.000000 | 5.000000 | 10.000000 | 20.000000 | 5.000000 | 1.00000 |
25% | 184.750000 | 50.000000 | 55.000000 | 50.000000 | 49.750000 | 50.000000 | 45.000000 | 2.00000 |
50% | 364.500000 | 65.000000 | 75.000000 | 70.000000 | 65.000000 | 70.000000 | 65.000000 | 3.00000 |
75% | 539.250000 | 80.000000 | 100.000000 | 90.000000 | 95.000000 | 90.000000 | 90.000000 | 5.00000 |
max | 721.000000 | 255.000000 | 190.000000 | 230.000000 | 194.000000 | 230.000000 | 180.000000 | 6.00000 |
df.sort_values('Name')
# | Name | Type 1 | Type 2 | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Generation | Legendary | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
510 | 460 | Abomasnow | Grass | Ice | 90 | 92 | 75 | 92 | 85 | 60 | 4 | False |
511 | 460 | AbomasnowMega Abomasnow | Grass | Ice | 90 | 132 | 105 | 132 | 105 | 30 | 4 | False |
68 | 63 | Abra | Psychic | NaN | 25 | 20 | 15 | 105 | 55 | 90 | 1 | False |
392 | 359 | Absol | Dark | NaN | 65 | 130 | 60 | 75 | 60 | 75 | 3 | False |
393 | 359 | AbsolMega Absol | Dark | NaN | 65 | 150 | 60 | 115 | 60 | 115 | 3 | False |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
632 | 571 | Zoroark | Dark | NaN | 60 | 105 | 60 | 120 | 60 | 105 | 5 | False |
631 | 570 | Zorua | Dark | NaN | 40 | 65 | 40 | 80 | 40 | 65 | 5 | False |
46 | 41 | Zubat | Poison | Flying | 40 | 45 | 35 | 30 | 40 | 55 | 1 | False |
695 | 634 | Zweilous | Dark | Dragon | 72 | 85 | 70 | 65 | 70 | 58 | 5 | False |
794 | 718 | Zygarde50% Forme | Dragon | Ground | 108 | 100 | 121 | 81 | 95 | 95 | 6 | True |
800 rows × 12 columns
df.sort_values('Name', ascending = False)
# | Name | Type 1 | Type 2 | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Generation | Legendary | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
794 | 718 | Zygarde50% Forme | Dragon | Ground | 108 | 100 | 121 | 81 | 95 | 95 | 6 | True |
695 | 634 | Zweilous | Dark | Dragon | 72 | 85 | 70 | 65 | 70 | 58 | 5 | False |
46 | 41 | Zubat | Poison | Flying | 40 | 45 | 35 | 30 | 40 | 55 | 1 | False |
631 | 570 | Zorua | Dark | NaN | 40 | 65 | 40 | 80 | 40 | 65 | 5 | False |
632 | 571 | Zoroark | Dark | NaN | 60 | 105 | 60 | 120 | 60 | 105 | 5 | False |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
393 | 359 | AbsolMega Absol | Dark | NaN | 65 | 150 | 60 | 115 | 60 | 115 | 3 | False |
392 | 359 | Absol | Dark | NaN | 65 | 130 | 60 | 75 | 60 | 75 | 3 | False |
68 | 63 | Abra | Psychic | NaN | 25 | 20 | 15 | 105 | 55 | 90 | 1 | False |
511 | 460 | AbomasnowMega Abomasnow | Grass | Ice | 90 | 132 | 105 | 132 | 105 | 30 | 4 | False |
510 | 460 | Abomasnow | Grass | Ice | 90 | 92 | 75 | 92 | 85 | 60 | 4 | False |
800 rows × 12 columns
df.sort_values(['Type 1', 'HP'], ascending = [1, 0])
# | Name | Type 1 | Type 2 | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Generation | Legendary | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
139 | 129 | Magikarp | Water | NaN | 20 | 10 | 55 | 15 | 20 | 80 | 1 | False |
381 | 349 | Feebas | Water | NaN | 20 | 15 | 20 | 10 | 55 | 80 | 3 | False |
97 | 90 | Shellder | Water | NaN | 30 | 65 | 100 | 45 | 25 | 40 | 1 | False |
106 | 98 | Krabby | Water | NaN | 30 | 105 | 90 | 25 | 25 | 50 | 1 | False |
125 | 116 | Horsea | Water | NaN | 30 | 40 | 70 | 70 | 25 | 60 | 1 | False |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
232 | 214 | HeracrossMega Heracross | Bug | Fighting | 80 | 185 | 115 | 40 | 105 | 75 | 2 | False |
678 | 617 | Accelgor | Bug | NaN | 80 | 70 | 40 | 100 | 60 | 145 | 5 | False |
734 | 666 | Vivillon | Bug | Flying | 80 | 52 | 50 | 90 | 50 | 89 | 6 | False |
698 | 637 | Volcarona | Bug | Fire | 85 | 60 | 65 | 135 | 105 | 100 | 5 | False |
520 | 469 | Yanmega | Bug | Flying | 86 | 76 | 86 | 116 | 56 | 95 | 4 | False |
800 rows × 12 columns
df['Total'] = df['HP'] + df['Attack'] + df['Defense'] + df['Sp. Atk'] + df['Sp. Def'] + df['Speed']
df.head()
# | Name | Type 1 | Type 2 | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Total | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Bulbasaur | Grass | Poison | 1 | False | 45 | 49 | 49 | 65 | 65 | 45 | 318 |
1 | 2 | Ivysaur | Grass | Poison | 1 | False | 60 | 62 | 63 | 80 | 80 | 60 | 405 |
2 | 3 | Venusaur | Grass | Poison | 1 | False | 80 | 82 | 83 | 100 | 100 | 80 | 525 |
3 | 3 | VenusaurMega Venusaur | Grass | Poison | 1 | False | 80 | 100 | 123 | 122 | 120 | 80 | 625 |
4 | 4 | Charmander | Fire | NaN | 1 | False | 39 | 52 | 43 | 60 | 50 | 65 | 309 |
df['Total'] = df.iloc[:, 4:12].sum(axis=1)
df.head(4)
# | Name | Type 1 | Type 2 | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Total | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Bulbasaur | Grass | Poison | 1 | False | 45 | 49 | 49 | 65 | 65 | 45 | 319.0 |
1 | 2 | Ivysaur | Grass | Poison | 1 | False | 60 | 62 | 63 | 80 | 80 | 60 | 406.0 |
2 | 3 | Venusaur | Grass | Poison | 1 | False | 80 | 82 | 83 | 100 | 100 | 80 | 526.0 |
3 | 3 | VenusaurMega Venusaur | Grass | Poison | 1 | False | 80 | 100 | 123 | 122 | 120 | 80 | 626.0 |
***Sum is 319 instead of 318 because the rows are rearranged therefore adding Legendary column too
cols = list(df.columns)
df = df[cols[0:4] + [cols[-1]]+cols[4:12]]
df.head()
# | Name | Type 1 | Type 2 | Generation | Legendary | Total | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Bulbasaur | Grass | Poison | 1 | False | 318 | 45 | 49 | 49 | 65 | 65 | 45 |
1 | 2 | Ivysaur | Grass | Poison | 1 | False | 405 | 60 | 62 | 63 | 80 | 80 | 60 |
2 | 3 | Venusaur | Grass | Poison | 1 | False | 525 | 80 | 82 | 83 | 100 | 100 | 80 |
3 | 3 | VenusaurMega Venusaur | Grass | Poison | 1 | False | 625 | 80 | 100 | 123 | 122 | 120 | 80 |
4 | 4 | Charmander | Fire | NaN | 1 | False | 309 | 39 | 52 | 43 | 60 | 50 | 65 |
df = df.drop(columns=['Total'])
df.head()
# | Name | Type 1 | Type 2 | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Bulbasaur | Grass | Poison | 1 | False | 45 | 49 | 49 | 65 | 65 | 45 |
1 | 2 | Ivysaur | Grass | Poison | 1 | False | 60 | 62 | 63 | 80 | 80 | 60 |
2 | 3 | Venusaur | Grass | Poison | 1 | False | 80 | 82 | 83 | 100 | 100 | 80 |
3 | 3 | VenusaurMega Venusaur | Grass | Poison | 1 | False | 80 | 100 | 123 | 122 | 120 | 80 |
4 | 4 | Charmander | Fire | NaN | 1 | False | 39 | 52 | 43 | 60 | 50 | 65 |
Saving as CSV
df.to_csv('modified_pokemon.csv', index = False)
#Saving as Excel
#df.to_excel('modified_pokemon.csv', index = False)
#Saving as TXT
#df.to_csv('modified_pokemon.csv', index = False, sep = '\t')
df.loc[(df['Type 1'] == 'Water') & (df['Type 2'] == 'Ice')]
# | Name | Type 1 | Type 2 | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Total | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
94 | 87 | Dewgong | Water | Ice | 1 | False | 90 | 70 | 80 | 70 | 95 | 70 | 475 |
98 | 91 | Cloyster | Water | Ice | 1 | False | 50 | 95 | 180 | 85 | 45 | 70 | 525 |
142 | 131 | Lapras | Water | Ice | 1 | False | 130 | 85 | 80 | 85 | 95 | 60 | 535 |
df.loc[(df['Type 1'] == 'Water') | (df['Type 2'] == 'Ice')]
# | Name | Type 1 | Type 2 | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Total | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9 | 7 | Squirtle | Water | NaN | 1 | False | 44 | 48 | 65 | 50 | 64 | 43 | 314 |
10 | 8 | Wartortle | Water | NaN | 1 | False | 59 | 63 | 80 | 65 | 80 | 58 | 405 |
11 | 9 | Blastoise | Water | NaN | 1 | False | 79 | 83 | 100 | 85 | 105 | 78 | 530 |
12 | 9 | BlastoiseMega Blastoise | Water | NaN | 1 | False | 79 | 103 | 120 | 135 | 115 | 78 | 630 |
59 | 54 | Psyduck | Water | NaN | 1 | False | 50 | 52 | 48 | 65 | 50 | 55 | 320 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
726 | 658 | Greninja | Water | Dark | 6 | False | 72 | 95 | 67 | 103 | 71 | 122 | 530 |
762 | 692 | Clauncher | Water | NaN | 6 | False | 50 | 53 | 62 | 58 | 63 | 44 | 330 |
763 | 693 | Clawitzer | Water | NaN | 6 | False | 71 | 73 | 88 | 120 | 89 | 59 | 500 |
768 | 698 | Amaura | Rock | Ice | 6 | False | 77 | 59 | 50 | 67 | 63 | 46 | 362 |
769 | 699 | Aurorus | Rock | Ice | 6 | False | 123 | 77 | 72 | 99 | 92 | 58 | 521 |
123 rows × 13 columns
new_df = df.loc[(df['Type 1'] == 'Ice') | (df['Speed'] > 50) & (df['Type 2'] == 'NaN' )]
new_df = new_df.reset_index(drop = True)
print(new_df)
# Name Type 1 Type 2 Generation Legendary HP \ 0 124 Jynx Ice Psychic 1 False 65 1 144 Articuno Ice Flying 1 True 90 2 220 Swinub Ice Ground 2 False 50 3 221 Piloswine Ice Ground 2 False 100 4 225 Delibird Ice Flying 2 False 45 5 238 Smoochum Ice Psychic 2 False 45 6 361 Snorunt Ice NaN 3 False 50 7 362 Glalie Ice NaN 3 False 80 8 362 GlalieMega Glalie Ice NaN 3 False 80 9 363 Spheal Ice Water 3 False 70 10 364 Sealeo Ice Water 3 False 90 11 365 Walrein Ice Water 3 False 110 12 378 Regice Ice NaN 3 True 80 13 471 Glaceon Ice NaN 4 False 65 14 473 Mamoswine Ice Ground 4 False 110 15 478 Froslass Ice Ghost 4 False 70 16 582 Vanillite Ice NaN 5 False 36 17 583 Vanillish Ice NaN 5 False 51 18 584 Vanilluxe Ice NaN 5 False 71 19 613 Cubchoo Ice NaN 5 False 55 20 614 Beartic Ice NaN 5 False 95 21 615 Cryogonal Ice NaN 5 False 70 22 712 Bergmite Ice NaN 6 False 55 23 713 Avalugg Ice NaN 6 False 95 Attack Defense Sp. Atk Sp. Def Speed Total 0 50 35 115 95 95 455 1 85 100 95 125 85 580 2 50 40 30 30 50 250 3 100 80 60 60 50 450 4 55 45 65 45 75 330 5 30 15 85 65 65 305 6 50 50 50 50 50 300 7 80 80 80 80 80 480 8 120 80 120 80 100 580 9 40 50 55 50 25 290 10 60 70 75 70 45 410 11 80 90 95 90 65 530 12 50 100 100 200 50 580 13 60 110 130 95 65 525 14 130 80 70 60 80 530 15 80 70 80 70 110 480 16 50 50 65 60 44 305 17 65 65 80 75 59 395 18 95 85 110 95 79 535 19 70 40 60 40 40 305 20 110 80 70 80 50 485 21 50 30 95 135 105 485 22 69 85 32 35 28 304 23 117 184 44 46 28 514
df.loc[~df['Name'].str.contains('Mega')]
# | Name | Type 1 | Type 2 | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Total | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Bulbasaur | Grass | Poison | 1 | False | 45 | 49 | 49 | 65 | 65 | 45 | 318 |
1 | 2 | Ivysaur | Grass | Poison | 1 | False | 60 | 62 | 63 | 80 | 80 | 60 | 405 |
2 | 3 | Venusaur | Grass | Poison | 1 | False | 80 | 82 | 83 | 100 | 100 | 80 | 525 |
4 | 4 | Charmander | Fire | NaN | 1 | False | 39 | 52 | 43 | 60 | 50 | 65 | 309 |
5 | 5 | Charmeleon | Fire | NaN | 1 | False | 58 | 64 | 58 | 80 | 65 | 80 | 405 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
794 | 718 | Zygarde50% Forme | Dragon | Ground | 6 | True | 108 | 100 | 121 | 81 | 95 | 95 | 600 |
795 | 719 | Diancie | Rock | Fairy | 6 | True | 50 | 100 | 150 | 100 | 150 | 50 | 600 |
797 | 720 | HoopaHoopa Confined | Psychic | Ghost | 6 | True | 80 | 110 | 60 | 150 | 130 | 70 | 600 |
798 | 720 | HoopaHoopa Unbound | Psychic | Dark | 6 | True | 80 | 160 | 60 | 170 | 130 | 80 | 680 |
799 | 721 | Volcanion | Fire | Water | 6 | True | 80 | 110 | 120 | 130 | 90 | 70 | 600 |
751 rows × 13 columns
import re
df.loc[df['Type 1'].str.contains('Fire|Grass', regex = True)]
# | Name | Type 1 | Type 2 | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Total | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Bulbasaur | Grass | Poison | 1 | False | 45 | 49 | 49 | 65 | 65 | 45 | 318 |
1 | 2 | Ivysaur | Grass | Poison | 1 | False | 60 | 62 | 63 | 80 | 80 | 60 | 405 |
2 | 3 | Venusaur | Grass | Poison | 1 | False | 80 | 82 | 83 | 100 | 100 | 80 | 525 |
3 | 3 | VenusaurMega Venusaur | Grass | Poison | 1 | False | 80 | 100 | 123 | 122 | 120 | 80 | 625 |
4 | 4 | Charmander | Fire | NaN | 1 | False | 39 | 52 | 43 | 60 | 50 | 65 | 309 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
735 | 667 | Litleo | Fire | Normal | 6 | False | 62 | 50 | 58 | 73 | 54 | 72 | 369 |
736 | 668 | Pyroar | Fire | Normal | 6 | False | 86 | 68 | 72 | 109 | 66 | 106 | 507 |
740 | 672 | Skiddo | Grass | NaN | 6 | False | 66 | 65 | 48 | 62 | 57 | 52 | 350 |
741 | 673 | Gogoat | Grass | NaN | 6 | False | 123 | 100 | 62 | 97 | 81 | 68 | 531 |
799 | 721 | Volcanion | Fire | Water | 6 | True | 80 | 110 | 120 | 130 | 90 | 70 | 600 |
122 rows × 13 columns
df.loc[df['Type 1'].str.contains('fire|grass', flags = re.I, regex = True)]
# | Name | Type 1 | Type 2 | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Total | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Bulbasaur | Grass | Poison | 1 | False | 45 | 49 | 49 | 65 | 65 | 45 | 318 |
1 | 2 | Ivysaur | Grass | Poison | 1 | False | 60 | 62 | 63 | 80 | 80 | 60 | 405 |
2 | 3 | Venusaur | Grass | Poison | 1 | False | 80 | 82 | 83 | 100 | 100 | 80 | 525 |
3 | 3 | VenusaurMega Venusaur | Grass | Poison | 1 | False | 80 | 100 | 123 | 122 | 120 | 80 | 625 |
4 | 4 | Charmander | Fire | NaN | 1 | False | 39 | 52 | 43 | 60 | 50 | 65 | 309 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
735 | 667 | Litleo | Fire | Normal | 6 | False | 62 | 50 | 58 | 73 | 54 | 72 | 369 |
736 | 668 | Pyroar | Fire | Normal | 6 | False | 86 | 68 | 72 | 109 | 66 | 106 | 507 |
740 | 672 | Skiddo | Grass | NaN | 6 | False | 66 | 65 | 48 | 62 | 57 | 52 | 350 |
741 | 673 | Gogoat | Grass | NaN | 6 | False | 123 | 100 | 62 | 97 | 81 | 68 | 531 |
799 | 721 | Volcanion | Fire | Water | 6 | True | 80 | 110 | 120 | 130 | 90 | 70 | 600 |
122 rows × 13 columns
df.loc[df['Name'].str.contains('^pi[a-z]*', flags = re.I, regex = True)]
# | Name | Type 1 | Type 2 | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Total | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
20 | 16 | Pidgey | Normal | Flying | 1 | False | 40 | 45 | 40 | 35 | 35 | 56 | 251 |
21 | 17 | Pidgeotto | Normal | Flying | 1 | False | 63 | 60 | 55 | 50 | 50 | 71 | 349 |
22 | 18 | Pidgeot | Normal | Flying | 1 | False | 83 | 80 | 75 | 70 | 70 | 101 | 479 |
23 | 18 | PidgeotMega Pidgeot | Normal | Flying | 1 | False | 83 | 80 | 80 | 135 | 80 | 121 | 579 |
30 | 25 | Pikachu | Electric | NaN | 1 | False | 35 | 55 | 40 | 50 | 50 | 90 | 320 |
136 | 127 | Pinsir | Bug | NaN | 1 | False | 65 | 125 | 100 | 55 | 70 | 85 | 500 |
137 | 127 | PinsirMega Pinsir | Bug | Flying | 1 | False | 65 | 155 | 120 | 65 | 90 | 105 | 600 |
186 | 172 | Pichu | Electric | NaN | 2 | False | 20 | 40 | 15 | 35 | 35 | 60 | 205 |
219 | 204 | Pineco | Bug | NaN | 2 | False | 50 | 65 | 90 | 35 | 35 | 15 | 290 |
239 | 221 | Piloswine | Ice | Ground | 2 | False | 100 | 100 | 80 | 60 | 60 | 50 | 450 |
438 | 393 | Piplup | Water | NaN | 4 | False | 53 | 51 | 53 | 61 | 56 | 40 | 314 |
558 | 499 | Pignite | Fire | Fighting | 5 | False | 90 | 93 | 55 | 70 | 55 | 55 | 418 |
578 | 519 | Pidove | Normal | Flying | 5 | False | 50 | 55 | 50 | 36 | 30 | 43 | 264 |
df.loc[df['Type 1'] == 'Fire', 'Type 1'] = 'Flamer'
df
# | Name | Type 1 | Type 2 | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Total | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Bulbasaur | Grass | Poison | 1 | False | 45 | 49 | 49 | 65 | 65 | 45 | 318 |
1 | 2 | Ivysaur | Grass | Poison | 1 | False | 60 | 62 | 63 | 80 | 80 | 60 | 405 |
2 | 3 | Venusaur | Grass | Poison | 1 | False | 80 | 82 | 83 | 100 | 100 | 80 | 525 |
3 | 3 | VenusaurMega Venusaur | Grass | Poison | 1 | False | 80 | 100 | 123 | 122 | 120 | 80 | 625 |
4 | 4 | Charmander | Flamer | NaN | 1 | False | 39 | 52 | 43 | 60 | 50 | 65 | 309 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
795 | 719 | Diancie | Rock | Fairy | 6 | True | 50 | 100 | 150 | 100 | 150 | 50 | 600 |
796 | 719 | DiancieMega Diancie | Rock | Fairy | 6 | True | 50 | 160 | 110 | 160 | 110 | 110 | 700 |
797 | 720 | HoopaHoopa Confined | Psychic | Ghost | 6 | True | 80 | 110 | 60 | 150 | 130 | 70 | 600 |
798 | 720 | HoopaHoopa Unbound | Psychic | Dark | 6 | True | 80 | 160 | 60 | 170 | 130 | 80 | 680 |
799 | 721 | Volcanion | Flamer | Water | 6 | True | 80 | 110 | 120 | 130 | 90 | 70 | 600 |
800 rows × 13 columns
df.loc[df['Type 1'] == 'Flamer', 'Type 1'] = 'Fire'
df
# | Name | Type 1 | Type 2 | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Total | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Bulbasaur | Grass | Poison | 1 | False | 45 | 49 | 49 | 65 | 65 | 45 | 318 |
1 | 2 | Ivysaur | Grass | Poison | 1 | False | 60 | 62 | 63 | 80 | 80 | 60 | 405 |
2 | 3 | Venusaur | Grass | Poison | 1 | False | 80 | 82 | 83 | 100 | 100 | 80 | 525 |
3 | 3 | VenusaurMega Venusaur | Grass | Poison | 1 | False | 80 | 100 | 123 | 122 | 120 | 80 | 625 |
4 | 4 | Charmander | Fire | NaN | 1 | False | 39 | 52 | 43 | 60 | 50 | 65 | 309 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
795 | 719 | Diancie | Rock | Fairy | 6 | True | 50 | 100 | 150 | 100 | 150 | 50 | 600 |
796 | 719 | DiancieMega Diancie | Rock | Fairy | 6 | True | 50 | 160 | 110 | 160 | 110 | 110 | 700 |
797 | 720 | HoopaHoopa Confined | Psychic | Ghost | 6 | True | 80 | 110 | 60 | 150 | 130 | 70 | 600 |
798 | 720 | HoopaHoopa Unbound | Psychic | Dark | 6 | True | 80 | 160 | 60 | 170 | 130 | 80 | 680 |
799 | 721 | Volcanion | Fire | Water | 6 | True | 80 | 110 | 120 | 130 | 90 | 70 | 600 |
800 rows × 13 columns
df.loc[df['Total'] > 500, ['Generation', 'Legendary']] = ['Good', 'Great']
df
# | Name | Type 1 | Type 2 | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Total | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Bulbasaur | Grass | Poison | 1 | False | 45 | 49 | 49 | 65 | 65 | 45 | 318 |
1 | 2 | Ivysaur | Grass | Poison | 1 | False | 60 | 62 | 63 | 80 | 80 | 60 | 405 |
2 | 3 | Venusaur | Grass | Poison | Good | Great | 80 | 82 | 83 | 100 | 100 | 80 | 525 |
3 | 3 | VenusaurMega Venusaur | Grass | Poison | Good | Great | 80 | 100 | 123 | 122 | 120 | 80 | 625 |
4 | 4 | Charmander | Fire | NaN | 1 | False | 39 | 52 | 43 | 60 | 50 | 65 | 309 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
795 | 719 | Diancie | Rock | Fairy | Good | Great | 50 | 100 | 150 | 100 | 150 | 50 | 600 |
796 | 719 | DiancieMega Diancie | Rock | Fairy | Good | Great | 50 | 160 | 110 | 160 | 110 | 110 | 700 |
797 | 720 | HoopaHoopa Confined | Psychic | Ghost | Good | Great | 80 | 110 | 60 | 150 | 130 | 70 | 600 |
798 | 720 | HoopaHoopa Unbound | Psychic | Dark | Good | Great | 80 | 160 | 60 | 170 | 130 | 80 | 680 |
799 | 721 | Volcanion | Fire | Water | Good | Great | 80 | 110 | 120 | 130 | 90 | 70 | 600 |
800 rows × 13 columns
df.groupby(['Type 1']).mean().sort_values('HP', ascending = False)
# | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Total | |
---|---|---|---|---|---|---|---|---|---|---|
Type 1 | ||||||||||
Dragon | 474.375000 | 3.875000 | 0.375000 | 83.312500 | 112.125000 | 86.375000 | 96.843750 | 88.843750 | 83.031250 | 550.531250 |
Normal | 319.173469 | 3.051020 | 0.020408 | 77.275510 | 73.469388 | 59.846939 | 55.816327 | 63.724490 | 71.551020 | 401.683673 |
Fairy | 449.529412 | 4.117647 | 0.058824 | 74.117647 | 61.529412 | 65.705882 | 78.529412 | 84.705882 | 48.588235 | 413.176471 |
Ground | 356.281250 | 3.156250 | 0.125000 | 73.781250 | 95.750000 | 84.843750 | 56.468750 | 62.750000 | 63.906250 | 437.500000 |
Water | 303.089286 | 2.857143 | 0.035714 | 72.062500 | 74.151786 | 72.946429 | 74.812500 | 70.517857 | 65.964286 | 430.455357 |
Ice | 423.541667 | 3.541667 | 0.083333 | 72.000000 | 72.750000 | 71.416667 | 77.541667 | 76.291667 | 63.458333 | 433.458333 |
Flying | 677.750000 | 5.500000 | 0.500000 | 70.750000 | 78.750000 | 66.250000 | 94.250000 | 72.500000 | 102.500000 | 485.000000 |
Psychic | 380.807018 | 3.385965 | 0.245614 | 70.631579 | 71.456140 | 67.684211 | 98.403509 | 86.280702 | 81.491228 | 475.947368 |
Fire | 327.403846 | 3.211538 | 0.096154 | 69.903846 | 84.769231 | 67.769231 | 88.980769 | 72.211538 | 74.442308 | 458.076923 |
Fighting | 363.851852 | 3.370370 | 0.000000 | 69.851852 | 96.777778 | 65.925926 | 53.111111 | 64.703704 | 66.074074 | 416.444444 |
Grass | 344.871429 | 3.357143 | 0.042857 | 67.271429 | 73.214286 | 70.800000 | 77.500000 | 70.428571 | 61.928571 | 421.142857 |
Poison | 251.785714 | 2.535714 | 0.000000 | 67.250000 | 74.678571 | 68.821429 | 60.428571 | 64.392857 | 63.571429 | 399.142857 |
Dark | 461.354839 | 4.032258 | 0.064516 | 66.806452 | 88.387097 | 70.225806 | 74.645161 | 69.516129 | 76.161290 | 445.741935 |
Rock | 392.727273 | 3.454545 | 0.090909 | 65.363636 | 92.863636 | 100.795455 | 63.340909 | 75.477273 | 55.909091 | 453.750000 |
Steel | 442.851852 | 3.851852 | 0.148148 | 65.222222 | 92.703704 | 126.370370 | 67.518519 | 80.629630 | 55.259259 | 487.703704 |
Ghost | 486.500000 | 4.187500 | 0.062500 | 64.437500 | 73.781250 | 81.187500 | 79.343750 | 76.468750 | 64.343750 | 439.562500 |
Electric | 363.500000 | 3.272727 | 0.090909 | 59.795455 | 69.090909 | 66.295455 | 90.022727 | 73.704545 | 84.500000 | 443.409091 |
Bug | 334.492754 | 3.217391 | 0.000000 | 56.884058 | 70.971014 | 70.724638 | 53.869565 | 64.797101 | 61.681159 | 378.927536 |
df.groupby(['Type 1']).mean().sort_values('Defense', ascending = False)
# | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Total | |
---|---|---|---|---|---|---|---|---|---|---|
Type 1 | ||||||||||
Steel | 442.851852 | 3.851852 | 0.148148 | 65.222222 | 92.703704 | 126.370370 | 67.518519 | 80.629630 | 55.259259 | 487.703704 |
Rock | 392.727273 | 3.454545 | 0.090909 | 65.363636 | 92.863636 | 100.795455 | 63.340909 | 75.477273 | 55.909091 | 453.750000 |
Dragon | 474.375000 | 3.875000 | 0.375000 | 83.312500 | 112.125000 | 86.375000 | 96.843750 | 88.843750 | 83.031250 | 550.531250 |
Ground | 356.281250 | 3.156250 | 0.125000 | 73.781250 | 95.750000 | 84.843750 | 56.468750 | 62.750000 | 63.906250 | 437.500000 |
Ghost | 486.500000 | 4.187500 | 0.062500 | 64.437500 | 73.781250 | 81.187500 | 79.343750 | 76.468750 | 64.343750 | 439.562500 |
Water | 303.089286 | 2.857143 | 0.035714 | 72.062500 | 74.151786 | 72.946429 | 74.812500 | 70.517857 | 65.964286 | 430.455357 |
Ice | 423.541667 | 3.541667 | 0.083333 | 72.000000 | 72.750000 | 71.416667 | 77.541667 | 76.291667 | 63.458333 | 433.458333 |
Grass | 344.871429 | 3.357143 | 0.042857 | 67.271429 | 73.214286 | 70.800000 | 77.500000 | 70.428571 | 61.928571 | 421.142857 |
Bug | 334.492754 | 3.217391 | 0.000000 | 56.884058 | 70.971014 | 70.724638 | 53.869565 | 64.797101 | 61.681159 | 378.927536 |
Dark | 461.354839 | 4.032258 | 0.064516 | 66.806452 | 88.387097 | 70.225806 | 74.645161 | 69.516129 | 76.161290 | 445.741935 |
Poison | 251.785714 | 2.535714 | 0.000000 | 67.250000 | 74.678571 | 68.821429 | 60.428571 | 64.392857 | 63.571429 | 399.142857 |
Fire | 327.403846 | 3.211538 | 0.096154 | 69.903846 | 84.769231 | 67.769231 | 88.980769 | 72.211538 | 74.442308 | 458.076923 |
Psychic | 380.807018 | 3.385965 | 0.245614 | 70.631579 | 71.456140 | 67.684211 | 98.403509 | 86.280702 | 81.491228 | 475.947368 |
Electric | 363.500000 | 3.272727 | 0.090909 | 59.795455 | 69.090909 | 66.295455 | 90.022727 | 73.704545 | 84.500000 | 443.409091 |
Flying | 677.750000 | 5.500000 | 0.500000 | 70.750000 | 78.750000 | 66.250000 | 94.250000 | 72.500000 | 102.500000 | 485.000000 |
Fighting | 363.851852 | 3.370370 | 0.000000 | 69.851852 | 96.777778 | 65.925926 | 53.111111 | 64.703704 | 66.074074 | 416.444444 |
Fairy | 449.529412 | 4.117647 | 0.058824 | 74.117647 | 61.529412 | 65.705882 | 78.529412 | 84.705882 | 48.588235 | 413.176471 |
Normal | 319.173469 | 3.051020 | 0.020408 | 77.275510 | 73.469388 | 59.846939 | 55.816327 | 63.724490 | 71.551020 | 401.683673 |
df.groupby(['Type 1']).mean().sort_values('Attack', ascending = False)
# | Generation | Legendary | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Total | |
---|---|---|---|---|---|---|---|---|---|---|
Type 1 | ||||||||||
Dragon | 474.375000 | 3.875000 | 0.375000 | 83.312500 | 112.125000 | 86.375000 | 96.843750 | 88.843750 | 83.031250 | 550.531250 |
Fighting | 363.851852 | 3.370370 | 0.000000 | 69.851852 | 96.777778 | 65.925926 | 53.111111 | 64.703704 | 66.074074 | 416.444444 |
Ground | 356.281250 | 3.156250 | 0.125000 | 73.781250 | 95.750000 | 84.843750 | 56.468750 | 62.750000 | 63.906250 | 437.500000 |
Rock | 392.727273 | 3.454545 | 0.090909 | 65.363636 | 92.863636 | 100.795455 | 63.340909 | 75.477273 | 55.909091 | 453.750000 |
Steel | 442.851852 | 3.851852 | 0.148148 | 65.222222 | 92.703704 | 126.370370 | 67.518519 | 80.629630 | 55.259259 | 487.703704 |
Dark | 461.354839 | 4.032258 | 0.064516 | 66.806452 | 88.387097 | 70.225806 | 74.645161 | 69.516129 | 76.161290 | 445.741935 |
Fire | 327.403846 | 3.211538 | 0.096154 | 69.903846 | 84.769231 | 67.769231 | 88.980769 | 72.211538 | 74.442308 | 458.076923 |
Flying | 677.750000 | 5.500000 | 0.500000 | 70.750000 | 78.750000 | 66.250000 | 94.250000 | 72.500000 | 102.500000 | 485.000000 |
Poison | 251.785714 | 2.535714 | 0.000000 | 67.250000 | 74.678571 | 68.821429 | 60.428571 | 64.392857 | 63.571429 | 399.142857 |
Water | 303.089286 | 2.857143 | 0.035714 | 72.062500 | 74.151786 | 72.946429 | 74.812500 | 70.517857 | 65.964286 | 430.455357 |
Ghost | 486.500000 | 4.187500 | 0.062500 | 64.437500 | 73.781250 | 81.187500 | 79.343750 | 76.468750 | 64.343750 | 439.562500 |
Normal | 319.173469 | 3.051020 | 0.020408 | 77.275510 | 73.469388 | 59.846939 | 55.816327 | 63.724490 | 71.551020 | 401.683673 |
Grass | 344.871429 | 3.357143 | 0.042857 | 67.271429 | 73.214286 | 70.800000 | 77.500000 | 70.428571 | 61.928571 | 421.142857 |
Ice | 423.541667 | 3.541667 | 0.083333 | 72.000000 | 72.750000 | 71.416667 | 77.541667 | 76.291667 | 63.458333 | 433.458333 |
Psychic | 380.807018 | 3.385965 | 0.245614 | 70.631579 | 71.456140 | 67.684211 | 98.403509 | 86.280702 | 81.491228 | 475.947368 |
Bug | 334.492754 | 3.217391 | 0.000000 | 56.884058 | 70.971014 | 70.724638 | 53.869565 | 64.797101 | 61.681159 | 378.927536 |
Electric | 363.500000 | 3.272727 | 0.090909 | 59.795455 | 69.090909 | 66.295455 | 90.022727 | 73.704545 | 84.500000 | 443.409091 |
Fairy | 449.529412 | 4.117647 | 0.058824 | 74.117647 | 61.529412 | 65.705882 | 78.529412 | 84.705882 | 48.588235 | 413.176471 |
df['Count'] = 1
df.groupby(['Type 1']).count()['Count']
Type 1 Bug 69 Dark 31 Dragon 32 Electric 44 Fairy 17 Fighting 27 Fire 52 Flying 4 Ghost 32 Grass 70 Ground 32 Ice 24 Normal 98 Poison 28 Psychic 57 Rock 44 Steel 27 Water 112 Name: Count, dtype: int64
df.groupby(['Type 1', 'Type 2']).count()['Count']
Type 1 Type 2 Bug Electric 2 Fighting 2 Fire 2 Flying 14 Ghost 1 .. Water Ice 3 Poison 3 Psychic 5 Rock 4 Steel 1 Name: Count, Length: 136, dtype: int64
big_df = pd.DataFrame(columns = df.columns)
for df in pd.read_csv('modified_pokemon.csv', chunksize = 5):
chunks = df.groupby(['Type 1']).count()
big_df = pd.concat([big_df, chunks])
print(big_df)
# Name Type 1 Type 2 Generation Legendary HP Attack Defense Sp. Atk \ Fire 1 1 NaN 0 1 1 1 1 1 1 Grass 4 4 NaN 4 4 4 4 4 4 4 Fire 4 4 NaN 3 4 4 4 4 4 4 Water 1 1 NaN 0 1 1 1 1 1 1 Bug 2 2 NaN 0 2 2 2 2 2 2 ... .. ... ... ... ... ... .. ... ... ... Fairy 1 1 NaN 0 1 1 1 1 1 1 Flying 2 2 NaN 2 2 2 2 2 2 2 Fire 1 1 NaN 1 1 1 1 1 1 1 Psychic 2 2 NaN 2 2 2 2 2 2 2 Rock 2 2 NaN 2 2 2 2 2 2 2 Sp. Def Speed Total Fire 1 1 1 Grass 4 4 4 Fire 4 4 4 Water 1 1 1 Bug 2 2 2 ... ... ... ... Fairy 1 1 1 Flying 2 2 2 Fire 1 1 1 Psychic 2 2 2 Rock 2 2 2 [433 rows x 13 columns]