DataFrame-数据检查
Published:
导入pandas库,为了方便起见也导入numpy库
import pandas as pd
import numpy as np
导入数据源
df = pd.read_csv("pokemon_data.csv",encoding="gbk")
df
姓名 | 类型1 | 类型2 | 总计 | 生命值 | 攻击力 | 防御力 | 速度 | 时代 | |
---|---|---|---|---|---|---|---|---|---|
0 | Bulbasaur | Grass | Poison | 318 | 45 | 49 | 49 | 45 | 1 |
1 | Ivysaur | Grass | Poison | 405 | 60 | 62 | 63 | 60 | 1 |
2 | Venusaur | Grass | Poison | 525 | 80 | 82 | 83 | 80 | 1 |
3 | VenusaurMega Venusaur | Grass | Poison | 625 | 80 | 100 | 123 | 80 | 1 |
4 | Charmander | Fire | NaN | 309 | 39 | 52 | 43 | 65 | 1 |
5 | Charmeleon | Fire | NaN | 405 | 58 | 64 | 58 | 80 | 1 |
6 | Charizard | Fire | Flying | 534 | 78 | 84 | 78 | 100 | 1 |
7 | CharizardMega Charizard X | Fire | Dragon | 634 | 78 | 130 | 111 | 100 | 1 |
8 | CharizardMega Charizard Y | Fire | Flying | 634 | 78 | 104 | 78 | 100 | 1 |
9 | Squirtle | Water | NaN | 314 | 44 | 48 | 65 | 43 | 1 |
10 | Wartortle | Water | NaN | 405 | 59 | 63 | 80 | 58 | 1 |
11 | Blastoise | Water | NaN | 530 | 79 | 83 | 100 | 78 | 1 |
12 | BlastoiseMega Blastoise | Water | NaN | 630 | 79 | 103 | 120 | 78 | 1 |
13 | Caterpie | Bug | NaN | 195 | 45 | 30 | 35 | 45 | 1 |
14 | Metapod | Bug | NaN | 205 | 50 | 20 | 55 | 30 | 1 |
15 | Butterfree | Bug | Flying | 395 | 60 | 45 | 50 | 70 | 1 |
16 | Weedle | Bug | Poison | 195 | 40 | 35 | 30 | 50 | 1 |
17 | Kakuna | Bug | Poison | 205 | 45 | 25 | 50 | 35 | 1 |
18 | Beedrill | Bug | Poison | 395 | 65 | 90 | 40 | 75 | 1 |
19 | BeedrillMega Beedrill | Bug | Poison | 495 | 65 | 150 | 40 | 145 | 1 |
20 | Pidgey | Normal | Flying | 251 | 40 | 45 | 40 | 56 | 1 |
21 | Pidgeotto | Normal | Flying | 349 | 63 | 60 | 55 | 71 | 1 |
22 | Pidgeot | Normal | Flying | 479 | 83 | 80 | 75 | 101 | 1 |
23 | PidgeotMega Pidgeot | Normal | Flying | 579 | 83 | 80 | 80 | 121 | 1 |
24 | Rattata | Normal | NaN | 253 | 30 | 56 | 35 | 72 | 1 |
25 | Raticate | Normal | NaN | 413 | 55 | 81 | 60 | 97 | 1 |
26 | Spearow | Normal | Flying | 262 | 40 | 60 | 30 | 70 | 1 |
27 | Fearow | Normal | Flying | 442 | 65 | 90 | 65 | 100 | 1 |
28 | Ekans | Poison | NaN | 288 | 35 | 60 | 44 | 55 | 1 |
29 | Arbok | Poison | NaN | 438 | 60 | 85 | 69 | 80 | 1 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
770 | Sylveon | Fairy | NaN | 525 | 95 | 65 | 65 | 60 | 6 |
771 | Hawlucha | Fighting | Flying | 500 | 78 | 92 | 75 | 118 | 6 |
772 | Dedenne | Electric | Fairy | 431 | 67 | 58 | 57 | 101 | 6 |
773 | Carbink | Rock | Fairy | 500 | 50 | 50 | 150 | 50 | 6 |
774 | Goomy | Dragon | NaN | 300 | 45 | 50 | 35 | 40 | 6 |
775 | Sliggoo | Dragon | NaN | 452 | 68 | 75 | 53 | 60 | 6 |
776 | Goodra | Dragon | NaN | 600 | 90 | 100 | 70 | 80 | 6 |
777 | Klefki | Steel | Fairy | 470 | 57 | 80 | 91 | 75 | 6 |
778 | Phantump | Ghost | Grass | 309 | 43 | 70 | 48 | 38 | 6 |
779 | Trevenant | Ghost | Grass | 474 | 85 | 110 | 76 | 56 | 6 |
780 | PumpkabooAverage Size | Ghost | Grass | 335 | 49 | 66 | 70 | 51 | 6 |
781 | PumpkabooSmall Size | Ghost | Grass | 335 | 44 | 66 | 70 | 56 | 6 |
782 | PumpkabooLarge Size | Ghost | Grass | 335 | 54 | 66 | 70 | 46 | 6 |
783 | PumpkabooSuper Size | Ghost | Grass | 335 | 59 | 66 | 70 | 41 | 6 |
784 | GourgeistAverage Size | Ghost | Grass | 494 | 65 | 90 | 122 | 84 | 6 |
785 | GourgeistSmall Size | Ghost | Grass | 494 | 55 | 85 | 122 | 99 | 6 |
786 | GourgeistLarge Size | Ghost | Grass | 494 | 75 | 95 | 122 | 69 | 6 |
787 | GourgeistSuper Size | Ghost | Grass | 494 | 85 | 100 | 122 | 54 | 6 |
788 | Bergmite | Ice | NaN | 304 | 55 | 69 | 85 | 28 | 6 |
789 | Avalugg | Ice | NaN | 514 | 95 | 117 | 184 | 28 | 6 |
790 | Noibat | Flying | Dragon | 245 | 40 | 30 | 35 | 55 | 6 |
791 | Noivern | Flying | Dragon | 535 | 85 | 70 | 80 | 123 | 6 |
792 | Xerneas | Fairy | NaN | 680 | 126 | 131 | 95 | 99 | 6 |
793 | Yveltal | Dark | Flying | 680 | 126 | 131 | 95 | 99 | 6 |
794 | Zygarde50% Forme | Dragon | Ground | 600 | 108 | 100 | 121 | 95 | 6 |
795 | Diancie | Rock | Fairy | 600 | 50 | 100 | 150 | 50 | 6 |
796 | DiancieMega Diancie | Rock | Fairy | 700 | 50 | 160 | 110 | 110 | 6 |
797 | HoopaHoopa Confined | Psychic | Ghost | 600 | 80 | 110 | 60 | 70 | 6 |
798 | HoopaHoopa Unbound | Psychic | Dark | 680 | 80 | 160 | 60 | 80 | 6 |
799 | Volcanion | Fire | Water | 600 | 80 | 110 | 120 | 70 | 6 |
800 rows × 9 columns
1.查看前5行和后5行
head()默认返回前面5行
df.head()
姓名 | 类型1 | 类型2 | 总计 | 生命值 | 攻击力 | 防御力 | 速度 | 时代 | |
---|---|---|---|---|---|---|---|---|---|
0 | Bulbasaur | Grass | Poison | 318 | 45 | 49 | 49 | 45 | 1 |
1 | Ivysaur | Grass | Poison | 405 | 60 | 62 | 63 | 60 | 1 |
2 | Venusaur | Grass | Poison | 525 | 80 | 82 | 83 | 80 | 1 |
3 | VenusaurMega Venusaur | Grass | Poison | 625 | 80 | 100 | 123 | 80 | 1 |
4 | Charmander | Fire | NaN | 309 | 39 | 52 | 43 | 65 | 1 |
从头开始指定查看行数
df.head(20)
姓名 | 类型1 | 类型2 | 总计 | 生命值 | 攻击力 | 防御力 | 速度 | 时代 | |
---|---|---|---|---|---|---|---|---|---|
0 | Bulbasaur | Grass | Poison | 318 | 45 | 49 | 49 | 45 | 1 |
1 | Ivysaur | Grass | Poison | 405 | 60 | 62 | 63 | 60 | 1 |
2 | Venusaur | Grass | Poison | 525 | 80 | 82 | 83 | 80 | 1 |
3 | VenusaurMega Venusaur | Grass | Poison | 625 | 80 | 100 | 123 | 80 | 1 |
4 | Charmander | Fire | NaN | 309 | 39 | 52 | 43 | 65 | 1 |
5 | Charmeleon | Fire | NaN | 405 | 58 | 64 | 58 | 80 | 1 |
6 | Charizard | Fire | Flying | 534 | 78 | 84 | 78 | 100 | 1 |
7 | CharizardMega Charizard X | Fire | Dragon | 634 | 78 | 130 | 111 | 100 | 1 |
8 | CharizardMega Charizard Y | Fire | Flying | 634 | 78 | 104 | 78 | 100 | 1 |
9 | Squirtle | Water | NaN | 314 | 44 | 48 | 65 | 43 | 1 |
10 | Wartortle | Water | NaN | 405 | 59 | 63 | 80 | 58 | 1 |
11 | Blastoise | Water | NaN | 530 | 79 | 83 | 100 | 78 | 1 |
12 | BlastoiseMega Blastoise | Water | NaN | 630 | 79 | 103 | 120 | 78 | 1 |
13 | Caterpie | Bug | NaN | 195 | 45 | 30 | 35 | 45 | 1 |
14 | Metapod | Bug | NaN | 205 | 50 | 20 | 55 | 30 | 1 |
15 | Butterfree | Bug | Flying | 395 | 60 | 45 | 50 | 70 | 1 |
16 | Weedle | Bug | Poison | 195 | 40 | 35 | 30 | 50 | 1 |
17 | Kakuna | Bug | Poison | 205 | 45 | 25 | 50 | 35 | 1 |
18 | Beedrill | Bug | Poison | 395 | 65 | 90 | 40 | 75 | 1 |
19 | BeedrillMega Beedrill | Bug | Poison | 495 | 65 | 150 | 40 | 145 | 1 |
tail()默认返回后面5行
df.tail()
姓名 | 类型1 | 类型2 | 总计 | 生命值 | 攻击力 | 防御力 | 速度 | 时代 | |
---|---|---|---|---|---|---|---|---|---|
795 | Diancie | Rock | Fairy | 600 | 50 | 100 | 150 | 50 | 6 |
796 | DiancieMega Diancie | Rock | Fairy | 700 | 50 | 160 | 110 | 110 | 6 |
797 | HoopaHoopa Confined | Psychic | Ghost | 600 | 80 | 110 | 60 | 70 | 6 |
798 | HoopaHoopa Unbound | Psychic | Dark | 680 | 80 | 160 | 60 | 80 | 6 |
799 | Volcanion | Fire | Water | 600 | 80 | 110 | 120 | 70 | 6 |
从尾查看指定查看行数
df.tail(20)
姓名 | 类型1 | 类型2 | 总计 | 生命值 | 攻击力 | 防御力 | 速度 | 时代 | |
---|---|---|---|---|---|---|---|---|---|
780 | PumpkabooAverage Size | Ghost | Grass | 335 | 49 | 66 | 70 | 51 | 6 |
781 | PumpkabooSmall Size | Ghost | Grass | 335 | 44 | 66 | 70 | 56 | 6 |
782 | PumpkabooLarge Size | Ghost | Grass | 335 | 54 | 66 | 70 | 46 | 6 |
783 | PumpkabooSuper Size | Ghost | Grass | 335 | 59 | 66 | 70 | 41 | 6 |
784 | GourgeistAverage Size | Ghost | Grass | 494 | 65 | 90 | 122 | 84 | 6 |
785 | GourgeistSmall Size | Ghost | Grass | 494 | 55 | 85 | 122 | 99 | 6 |
786 | GourgeistLarge Size | Ghost | Grass | 494 | 75 | 95 | 122 | 69 | 6 |
787 | GourgeistSuper Size | Ghost | Grass | 494 | 85 | 100 | 122 | 54 | 6 |
788 | Bergmite | Ice | NaN | 304 | 55 | 69 | 85 | 28 | 6 |
789 | Avalugg | Ice | NaN | 514 | 95 | 117 | 184 | 28 | 6 |
790 | Noibat | Flying | Dragon | 245 | 40 | 30 | 35 | 55 | 6 |
791 | Noivern | Flying | Dragon | 535 | 85 | 70 | 80 | 123 | 6 |
792 | Xerneas | Fairy | NaN | 680 | 126 | 131 | 95 | 99 | 6 |
793 | Yveltal | Dark | Flying | 680 | 126 | 131 | 95 | 99 | 6 |
794 | Zygarde50% Forme | Dragon | Ground | 600 | 108 | 100 | 121 | 95 | 6 |
795 | Diancie | Rock | Fairy | 600 | 50 | 100 | 150 | 50 | 6 |
796 | DiancieMega Diancie | Rock | Fairy | 700 | 50 | 160 | 110 | 110 | 6 |
797 | HoopaHoopa Confined | Psychic | Ghost | 600 | 80 | 110 | 60 | 70 | 6 |
798 | HoopaHoopa Unbound | Psychic | Dark | 680 | 80 | 160 | 60 | 80 | 6 |
799 | Volcanion | Fire | Water | 600 | 80 | 110 | 120 | 70 | 6 |
2.查看列名
df.columns
Index(['姓名', '类型1', '类型2', '总计', '生命值', '攻击力', '防御力', '速度', '时代'], dtype='object')
for i in df.columns:
print(i)
姓名
类型1
类型2
总计
生命值
攻击力
防御力
速度
时代
3.查看索引
df.index
RangeIndex(start=0, stop=800, step=1)
[print(i) for i in df.index]
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
[None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None]
4.查看行列数
df.shape
(800, 9)
5.查看数据类型
查看所有列的数据类型
df.dtypes
姓名 object
类型1 object
类型2 object
总计 int64
生命值 int64
攻击力 int64
防御力 int64
速度 int64
时代 int64
dtype: object
查看某列的数据类型
df["攻击力"].dtypes
dtype('int64')
6.查看空值
df.isnull().head()
姓名 | 类型1 | 类型2 | 总计 | 生命值 | 攻击力 | 防御力 | 速度 | 时代 | |
---|---|---|---|---|---|---|---|---|---|
0 | False | False | False | False | False | False | False | False | False |
1 | False | False | False | False | False | False | False | False | False |
2 | False | False | False | False | False | False | False | False | False |
3 | False | False | False | False | False | False | False | False | False |
4 | False | False | True | False | False | False | False | False | False |
df[df["类型2"].isnull()]
姓名 | 类型1 | 类型2 | 总计 | 生命值 | 攻击力 | 防御力 | 速度 | 时代 | |
---|---|---|---|---|---|---|---|---|---|
4 | Charmander | Fire | NaN | 309 | 39 | 52 | 43 | 65 | 1 |
5 | Charmeleon | Fire | NaN | 405 | 58 | 64 | 58 | 80 | 1 |
9 | Squirtle | Water | NaN | 314 | 44 | 48 | 65 | 43 | 1 |
10 | Wartortle | Water | NaN | 405 | 59 | 63 | 80 | 58 | 1 |
11 | Blastoise | Water | NaN | 530 | 79 | 83 | 100 | 78 | 1 |
12 | BlastoiseMega Blastoise | Water | NaN | 630 | 79 | 103 | 120 | 78 | 1 |
13 | Caterpie | Bug | NaN | 195 | 45 | 30 | 35 | 45 | 1 |
14 | Metapod | Bug | NaN | 205 | 50 | 20 | 55 | 30 | 1 |
24 | Rattata | Normal | NaN | 253 | 30 | 56 | 35 | 72 | 1 |
25 | Raticate | Normal | NaN | 413 | 55 | 81 | 60 | 97 | 1 |
28 | Ekans | Poison | NaN | 288 | 35 | 60 | 44 | 55 | 1 |
29 | Arbok | Poison | NaN | 438 | 60 | 85 | 69 | 80 | 1 |
30 | Pikachu | Electric | NaN | 320 | 35 | 55 | 40 | 90 | 1 |
31 | Raichu | Electric | NaN | 485 | 60 | 90 | 55 | 110 | 1 |
32 | Sandshrew | Ground | NaN | 300 | 50 | 75 | 85 | 40 | 1 |
33 | Sandslash | Ground | NaN | 450 | 75 | 100 | 110 | 65 | 1 |
34 | Nidoran♀ | Poison | NaN | 275 | 55 | 47 | 52 | 41 | 1 |
35 | Nidorina | Poison | NaN | 365 | 70 | 62 | 67 | 56 | 1 |
37 | Nidoran♂ | Poison | NaN | 273 | 46 | 57 | 40 | 50 | 1 |
38 | Nidorino | Poison | NaN | 365 | 61 | 72 | 57 | 65 | 1 |
40 | Clefairy | Fairy | NaN | 323 | 70 | 45 | 48 | 35 | 1 |
41 | Clefable | Fairy | NaN | 483 | 95 | 70 | 73 | 60 | 1 |
42 | Vulpix | Fire | NaN | 299 | 38 | 41 | 40 | 65 | 1 |
43 | Ninetales | Fire | NaN | 505 | 73 | 76 | 75 | 100 | 1 |
55 | Diglett | Ground | NaN | 265 | 10 | 55 | 25 | 95 | 1 |
56 | Dugtrio | Ground | NaN | 405 | 35 | 80 | 50 | 120 | 1 |
57 | Meowth | Normal | NaN | 290 | 40 | 45 | 35 | 90 | 1 |
58 | Persian | Normal | NaN | 440 | 65 | 70 | 60 | 115 | 1 |
59 | Psyduck | Water | NaN | 320 | 50 | 52 | 48 | 55 | 1 |
60 | Golduck | Water | NaN | 500 | 80 | 82 | 78 | 85 | 1 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
721 | Fennekin | Fire | NaN | 307 | 40 | 45 | 40 | 60 | 6 |
722 | Braixen | Fire | NaN | 409 | 59 | 59 | 58 | 73 | 6 |
724 | Froakie | Water | NaN | 314 | 41 | 56 | 40 | 71 | 6 |
725 | Frogadier | Water | NaN | 405 | 54 | 63 | 52 | 97 | 6 |
727 | Bunnelby | Normal | NaN | 237 | 38 | 36 | 38 | 57 | 6 |
732 | Scatterbug | Bug | NaN | 200 | 38 | 35 | 40 | 35 | 6 |
733 | Spewpa | Bug | NaN | 213 | 45 | 22 | 60 | 29 | 6 |
737 | Flabébé | Fairy | NaN | 303 | 44 | 38 | 39 | 42 | 6 |
738 | Floette | Fairy | NaN | 371 | 54 | 45 | 47 | 52 | 6 |
739 | Florges | Fairy | NaN | 552 | 78 | 65 | 68 | 75 | 6 |
740 | Skiddo | Grass | NaN | 350 | 66 | 65 | 48 | 52 | 6 |
741 | Gogoat | Grass | NaN | 531 | 123 | 100 | 62 | 68 | 6 |
742 | Pancham | Fighting | NaN | 348 | 67 | 82 | 62 | 43 | 6 |
744 | Furfrou | Normal | NaN | 472 | 75 | 80 | 60 | 102 | 6 |
745 | Espurr | Psychic | NaN | 355 | 62 | 48 | 54 | 68 | 6 |
746 | MeowsticMale | Psychic | NaN | 466 | 74 | 48 | 76 | 104 | 6 |
747 | MeowsticFemale | Psychic | NaN | 466 | 74 | 48 | 76 | 104 | 6 |
752 | Spritzee | Fairy | NaN | 341 | 78 | 52 | 60 | 23 | 6 |
753 | Aromatisse | Fairy | NaN | 462 | 101 | 72 | 72 | 29 | 6 |
754 | Swirlix | Fairy | NaN | 341 | 62 | 48 | 66 | 49 | 6 |
755 | Slurpuff | Fairy | NaN | 480 | 82 | 80 | 86 | 72 | 6 |
762 | Clauncher | Water | NaN | 330 | 50 | 53 | 62 | 44 | 6 |
763 | Clawitzer | Water | NaN | 500 | 71 | 73 | 88 | 59 | 6 |
770 | Sylveon | Fairy | NaN | 525 | 95 | 65 | 65 | 60 | 6 |
774 | Goomy | Dragon | NaN | 300 | 45 | 50 | 35 | 40 | 6 |
775 | Sliggoo | Dragon | NaN | 452 | 68 | 75 | 53 | 60 | 6 |
776 | Goodra | Dragon | NaN | 600 | 90 | 100 | 70 | 80 | 6 |
788 | Bergmite | Ice | NaN | 304 | 55 | 69 | 85 | 28 | 6 |
789 | Avalugg | Ice | NaN | 514 | 95 | 117 | 184 | 28 | 6 |
792 | Xerneas | Fairy | NaN | 680 | 126 | 131 | 95 | 99 | 6 |
386 rows × 9 columns
7.查看数据表信息
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 800 entries, 0 to 799
Data columns (total 9 columns):
姓名 800 non-null object
类型1 800 non-null object
类型2 414 non-null object
总计 800 non-null int64
生命值 800 non-null int64
攻击力 800 non-null int64
防御力 800 non-null int64
速度 800 non-null int64
时代 800 non-null int64
dtypes: int64(6), object(3)
memory usage: 56.3+ KB
8.查看唯一值
df["类型1"].unique()
array(['Grass', 'Fire', 'Water', 'Bug', 'Normal', 'Poison', 'Electric',
'Ground', 'Fairy', 'Fighting', 'Psychic', 'Rock', 'Ghost', 'Ice',
'Dragon', 'Dark', 'Steel', 'Flying'], dtype=object)
所有唯一值的数量
len(df["类型1"].unique())
18
每个值出现的次数(频次)
df["类型1"].value_counts()
Water 112
Normal 98
Grass 70
Bug 69
Psychic 57
Fire 52
Rock 44
Electric 44
Ghost 32
Dragon 32
Ground 32
Dark 31
Poison 28
Fighting 27
Steel 27
Ice 24
Fairy 17
Flying 4
Name: 类型1, dtype: int64