当前,足球运动是最受欢迎的运动之一(也可以说没有之一)。
我们的任务,就是在众多的足球运动员中,发现统计一些关于足球运动员的共性,或某些潜在的规律。
数据集包含的是2017年所有活跃的足球运动员。
导入需要的库,同时,进行一些初始化的设置。
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
# 支持中文显示。
mpl.rcParams["font.family"] = "SimHei"
mpl.rcParams["axes.unicode_minus"] = False
data = pd.read_csv("FullData.csv")
# data.head(10)
# data.sample(3)
pd.set_option("display.max_columns", 55)
data.head()
# data.info()
# 查看存在空值的记录。
# data[data["Club_Position"].isnull()]
# data.isnull().sum(axis=0)
# data["Club_Position"].notnull()
# 过滤空值记录。
# data = data[data["Club_Position"].notnull()]
# data.info()
# data.describe()
# data["Rating"].plot(kind="box")
# np.sum(data.duplicated())
# data[data.duplicated()]
# data.drop_duplicates()
# 对数据列进行转换。可以使用apply或map。
# data["Height"] =
# data["Height"] = data["Height"].apply(lambda item: item.replace("cm", "")).astype(np.int32)
# data["Weight"] = data["Weight"].apply(lambda item: item.replace("kg", "")).astype(np.int32)
# 也可以使用map实现同样的转换。
#data["Height"].map(lambda item: item.replace("cm", "")).astype(np.int32)
# 使用字符串的矢量化运算完成转换。
data["Height"] = data["Height"].str.replace("cm", "").astype(np.int32)
data["Weight"] = data["Weight"].str.replace("kg", "").astype(np.int32)
# data["Height"].plot(kind="kde")
# data["Weight"].plot(kind="kde")
# data["Rating"].plot(kind="kde")
data[["Height", "Weight", "Rating"]].plot(kind="kde")
# 第一种方式
# g = data.groupby("Preffered_Foot")
# g["Preffered_Foot"].count()
# 第二种方式
# g = data.groupby("Preffered_Foot")
# g.size()
# 第三种方式
data["Preffered_Foot"].value_counts().plot(kind="bar")
# 俱乐部
# g = data.groupby("Club")
# g["Rating"].mean().sort_values(ascending=False)
# t = g["Rating"].agg(["mean", "count"])
# t = t[t["count"] > 20]
# t = t.sort_values(by="mean", ascending=False).head(10)
# t["mean"].plot(kind="bar")
# 国家队
g = data.groupby("Nationality")
# g["Rating"].mean().sort_values(ascending=False)
t = g["Rating"].agg(["mean", "count"])
t = t[t["count"] > 20]
t = t.sort_values(by="mean", ascending=False).head(10)
t
# t["mean"].plot(kind="bar")
t = data["Club_Joining"].apply(lambda item: int(item.split("/")[-1]))
# 计算球员的效力时间。
year = 2017 - t
# 对数据集进行过滤,只保留效力时间达到或超过5年的球员。
t = data[(year >= 5) & (data["Club"] != "Free Agents")]
# t
t["Club"].value_counts()
# 全体运行员
# expand 默认为False。如果设置为True,就是展开成为一个DataFrame。
t = data["Birth_Date"].str.split("/", expand=True)
# t[2].value_counts().plot(kind="bar")
# t[0].value_counts().plot(kind="bar")
# t[1].value_counts().plot(kind="bar")
# 80分以上的运动员
t = data[data["Rating"] >= 80]
t = t["Birth_Date"].str.split("/", expand=True)
# t[2].value_counts().plot(kind="bar")
# t[0].value_counts().plot(kind="bar")
# t[1].value_counts().plot(kind="bar")
Out[74]:
# 去掉替补与预备队的球员
t = data[(data["Club_Position"] != "Res") & (data["Club_Position"] != "Sub")]
# g = data.groupby(["Club_Position", "Club_Kit"])
g = t.groupby(["Club_Kit", "Club_Position"])
g.size()
Out[78]:
Club_Kit Club_Position
1.0 GK 333
2.0 CAM 1
CB 3
GK 1
LB 26
LCB 36
LCM 3
LDM 3
LM 5
LW 1
LWB 1
RB 148
RCB 41
RCM 4
RDM 3
RM 3
RWB 11
3.0 CAM 1
CB 5
CDM 1
CM 2
LB 103
LCB 58
LCM 2
LDM 6
LM 3
LW 1
LWB 12
RB 19
RCB 75
...
93.0 LM 2
LS 1
LW 1
RCM 1
ST 1
94.0 CAM 2
RB 1
RCB 1
RCM 1
RM 1
RS 1
RW 1
95.0 LB 1
LM 2
RB 1
RM 1
96.0 LB 1
97.0 CAM 1
CM 1
ST 1
98.0 LB 1
LCM 1
RDM 1
99.0 CAM 1
GK 4
LM 1
LS 4
LW 1
RS 2
ST 8
Length: 954, dtype: int64
# data.plot(kind="scatter", x="Height", y="Weight")
# data.plot(kind="scatter", x="Height", y="Rating")
Out[80]:
data.corr()
Out[82]:
National_Kit | Club_Kit | Contract_Expiry | Rating | Height | Weight | Age | Weak_foot | Skill_Moves | Ball_Control | Dribbling | Marking | Sliding_Tackle | Standing_Tackle | Aggression | Reactions | Attacking_Position | Interceptions | Vision | Composure | Crossing | Short_Pass | Long_Pass | Acceleration | Speed | Stamina | Strength | Balance | Agility | Jumping | Heading | Shot_Power | Finishing | Long_Shots | Curve | Freekick_Accuracy | Penalties | Volleys | GK_Positioning | GK_Diving | GK_Kicking | GK_Handling | GK_Reflexes | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
National_Kit | 1.000000 | 0.055408 | -0.027211 | -0.084289 | -0.101229 | -0.093795 | -0.103583 | 0.027268 | 0.105903 | 0.046644 | 0.093836 | -0.162083 | -0.152251 | -0.148329 | -0.073288 | -0.058696 | 0.124641 | -0.154804 | 0.076988 | -0.016093 | 0.045986 | 0.036071 | -0.006230 | 0.079866 | 0.056282 | 0.003828 | -0.099086 | 0.089038 | 0.085691 | -0.100935 | -0.072020 | 0.083610 | 0.138914 | 0.109168 | 0.081888 | 0.106621 | 0.095289 | 0.117381 | -0.031492 | -0.012435 | -0.015472 | -0.024611 | -0.018816 |
Club_Kit | 0.055408 | 1.000000 | 0.077060 | -0.172710 | -0.028711 | -0.072341 | -0.198230 | -0.037234 | 0.006378 | -0.071067 | -0.028584 | -0.105522 | -0.094920 | -0.104446 | -0.121709 | -0.148887 | -0.031746 | -0.125007 | -0.071177 | -0.117220 | -0.067383 | -0.085123 | -0.100525 | -0.006315 | -0.010092 | -0.101258 | -0.141140 | 0.010762 | -0.036128 | -0.106797 | -0.076264 | -0.051829 | -0.007898 | -0.040658 | -0.053631 | -0.062077 | -0.016220 | -0.020482 | 0.004684 | 0.011290 | 0.008788 | 0.006725 | 0.007480 |
Contract_Expiry | -0.027211 | 0.077060 | 1.000000 | 0.047430 | -0.080641 | -0.053049 | -0.118370 | 0.004865 | 0.044511 | 0.035324 | 0.048664 | 0.015409 | 0.011482 | 0.008307 | -0.010361 | 0.051309 | 0.043698 | 0.006995 | 0.028113 | 0.005840 | 0.012553 | 0.034513 | 0.016371 | 0.071003 | 0.079394 | 0.053830 | -0.012495 | 0.046095 | 0.047667 | 0.002805 | 0.026235 | 0.021477 | 0.032341 | 0.028781 | 0.010840 | 0.007001 | 0.020878 | 0.025120 | -0.027994 | -0.026117 | -0.023273 | -0.023064 | -0.024923 |
Rating | -0.084289 | -0.172710 | 0.047430 | 1.000000 | 0.046937 | 0.139703 | 0.458098 | 0.226263 | 0.251926 | 0.463211 | 0.368565 | 0.236843 | 0.215385 | 0.249156 | 0.404422 | 0.828329 | 0.354501 | 0.319504 | 0.489277 | 0.613612 | 0.401851 | 0.496239 | 0.483217 | 0.206392 | 0.224253 | 0.355335 | 0.369045 | 0.087811 | 0.283309 | 0.289840 | 0.343265 | 0.441773 | 0.328576 | 0.419517 | 0.420796 | 0.399575 | 0.339898 | 0.386494 | -0.018586 | -0.027615 | -0.031696 | -0.021343 | -0.022978 |
Height | -0.101229 | -0.028711 | -0.080641 | 0.046937 | 1.000000 | 0.758208 | 0.076727 | -0.180431 | -0.431177 | -0.402596 | -0.483545 | -0.042485 | -0.069602 | -0.054282 | -0.049009 | -0.016407 | -0.419544 | -0.050358 | -0.359610 | -0.169460 | -0.471327 | -0.356768 | -0.323575 | -0.521688 | -0.451128 | -0.293564 | 0.537223 | -0.799775 | -0.611198 | -0.063048 | 0.005367 | -0.273413 | -0.347154 | -0.364182 | -0.423115 | -0.380217 | -0.321246 | -0.333576 | 0.358795 | 0.357683 | 0.356070 | 0.359746 | 0.360260 |
Weight | -0.093795 | -0.072341 | -0.053049 | 0.139703 | 0.758208 | 1.000000 | 0.223432 | -0.135402 | -0.375163 | -0.338460 | -0.412959 | -0.030512 | -0.062312 | -0.047097 | 0.017366 | 0.079019 | -0.344840 | -0.028947 | -0.283098 | -0.083541 | -0.389293 | -0.299264 | -0.261611 | -0.465558 | -0.404240 | -0.241365 | 0.613829 | -0.680791 | -0.535404 | 0.005842 | 0.019235 | -0.188739 | -0.281775 | -0.274446 | -0.343380 | -0.293956 | -0.246189 | -0.258932 | 0.342502 | 0.340775 | 0.339505 | 0.341829 | 0.341785 |
Age | -0.103583 | -0.198230 | -0.118370 | 0.458098 | 0.076727 | 0.223432 | 1.000000 | 0.086137 | -0.016088 | 0.082875 | 0.004575 | 0.131425 | 0.096679 | 0.116847 | 0.259413 | 0.456724 | 0.073873 | 0.192667 | 0.189982 | 0.355588 | 0.134576 | 0.127537 | 0.179109 | -0.175966 | -0.168440 | 0.070685 | 0.329289 | -0.100131 | -0.019459 | 0.168694 | 0.137785 | 0.151174 | 0.064487 | 0.149635 | 0.139101 | 0.195338 | 0.131469 | 0.133950 | 0.122371 | 0.105158 | 0.109931 | 0.113216 | 0.106979 |
Weak_foot | 0.027268 | -0.037234 | 0.004865 | 0.226263 | -0.180431 | -0.135402 | 0.086137 | 1.000000 | 0.336905 | 0.367420 | 0.363398 | 0.026950 | 0.025865 | 0.043656 | 0.134120 | 0.207098 | 0.354699 | 0.058148 | 0.352235 | 0.316486 | 0.324117 | 0.338919 | 0.298103 | 0.257156 | 0.240919 | 0.228619 | -0.004841 | 0.253466 | 0.306049 | 0.064655 | 0.190847 | 0.334897 | 0.361983 | 0.365637 | 0.359044 | 0.345745 | 0.340757 | 0.366610 | -0.232109 | -0.236372 | -0.230924 | -0.233080 | -0.235275 |
Skill_Moves | 0.105903 | 0.006378 | 0.044511 | 0.251926 | -0.431177 | -0.375163 | -0.016088 | 0.336905 | 1.000000 | 0.727123 | 0.762623 | 0.032811 | 0.043037 | 0.070841 | 0.230424 | 0.223236 | 0.719577 | 0.067407 | 0.591623 | 0.490854 | 0.644761 | 0.628088 | 0.515631 | 0.619623 | 0.598727 | 0.469200 | -0.117029 | 0.542743 | 0.637400 | 0.035166 | 0.391626 | 0.640183 | 0.715228 | 0.680434 | 0.689265 | 0.634867 | 0.662108 | 0.701017 | -0.607676 | -0.610500 | -0.605746 | -0.606713 | -0.609282 |
Ball_Control | 0.046644 | -0.071067 | 0.035324 | 0.463211 | -0.402596 | -0.338460 | 0.082875 | 0.367420 | 0.727123 | 1.000000 | 0.931117 | 0.355429 | 0.357025 | 0.391689 | 0.543142 | 0.424991 | 0.855487 | 0.392803 | 0.732518 | 0.704726 | 0.838775 | 0.904398 | 0.793084 | 0.669026 | 0.665755 | 0.724758 | 0.079898 | 0.573786 | 0.695569 | 0.172802 | 0.658111 | 0.829902 | 0.781218 | 0.831846 | 0.832009 | 0.763315 | 0.767803 | 0.789287 | -0.776117 | -0.779922 | -0.775690 | -0.775632 | -0.777668 |
Dribbling | 0.093836 | -0.028584 | 0.048664 | 0.368565 | -0.483545 | -0.412959 | 0.004575 | 0.363398 | 0.762623 | 0.931117 | 1.000000 | 0.228543 | 0.243277 | 0.270005 | 0.426393 | 0.349111 | 0.888391 | 0.264903 | 0.736197 | 0.627388 | 0.848864 | 0.833578 | 0.717857 | 0.740657 | 0.725716 | 0.676495 | -0.046376 | 0.638638 | 0.754705 | 0.117374 | 0.548257 | 0.795016 | 0.817034 | 0.836080 | 0.840061 | 0.750014 | 0.765259 | 0.804633 | -0.741793 | -0.743848 | -0.739995 | -0.740616 | -0.742065 |
Marking | -0.162083 | -0.105522 | 0.015409 | 0.236843 | -0.042485 | -0.030512 | 0.131425 | 0.026950 | 0.032811 | 0.355429 | 0.228543 | 1.000000 | 0.959955 | 0.960272 | 0.708671 | 0.218235 | 0.089095 | 0.922118 | 0.097899 | 0.327939 | 0.384596 | 0.476693 | 0.535364 | 0.138092 | 0.163242 | 0.538772 | 0.327395 | 0.117471 | 0.085645 | 0.258669 | 0.546994 | 0.219159 | -0.096066 | 0.116621 | 0.206493 | 0.233461 | 0.062951 | 0.013556 | -0.492932 | -0.496354 | -0.495732 | -0.496431 | -0.497013 |
Sliding_Tackle | -0.152251 | -0.094920 | 0.011482 | 0.215385 | -0.069602 | -0.062312 | 0.096679 | 0.025865 | 0.043037 | 0.357025 | 0.243277 | 0.959955 | 1.000000 | 0.971730 | 0.702852 | 0.200828 | 0.097474 | 0.915207 | 0.108223 | 0.314994 | 0.400583 | 0.479273 | 0.540317 | 0.159178 | 0.181316 | 0.538313 | 0.287903 | 0.145242 | 0.103459 | 0.254936 | 0.523946 | 0.217468 | -0.098796 | 0.117163 | 0.216875 | 0.241188 | 0.059355 | 0.015133 | -0.498386 | -0.501643 | -0.501019 | -0.501429 | -0.501738 |
Standing_Tackle | -0.148329 | -0.104446 | 0.008307 | 0.249156 | -0.054282 | -0.047097 | 0.116847 | 0.043656 | 0.070841 | 0.391689 | 0.270005 | 0.960272 | 0.971730 | 1.000000 | 0.728240 | 0.230117 | 0.130957 | 0.930060 | 0.143787 | 0.353054 | 0.417381 | 0.514137 | 0.567442 | 0.158883 | 0.182390 | 0.561885 | 0.321261 | 0.139473 | 0.110567 | 0.255130 | 0.555447 | 0.256805 | -0.058670 | 0.156849 | 0.247088 | 0.274715 | 0.096483 | 0.053435 | -0.521127 | -0.524291 | -0.523387 | -0.523648 | -0.524598 |
Aggression | -0.073288 | -0.121709 | -0.010361 | 0.404422 | -0.049009 | 0.017366 | 0.259413 | 0.134120 | 0.230424 | 0.543142 | 0.426393 | 0.708671 | 0.702852 | 0.728240 | 1.000000 | 0.390453 | 0.371589 | 0.736112 | 0.312152 | 0.534981 | 0.476202 | 0.597913 | 0.583940 | 0.260563 | 0.291840 | 0.643250 | 0.450040 | 0.172027 | 0.239329 | 0.352169 | 0.677640 | 0.496297 | 0.230695 | 0.386260 | 0.395877 | 0.402368 | 0.329841 | 0.318366 | -0.561675 | -0.567497 | -0.563989 | -0.564734 | -0.566184 |
Reactions | -0.058696 | -0.148887 | 0.051309 | 0.828329 | -0.016407 | 0.079019 | 0.456724 | 0.207098 | 0.223236 | 0.424991 | 0.349111 | 0.218235 | 0.200828 | 0.230117 | 0.390453 | 1.000000 | 0.373846 | 0.318822 | 0.482080 | 0.589313 | 0.381557 | 0.457700 | 0.444277 | 0.183576 | 0.188701 | 0.346043 | 0.290929 | 0.130092 | 0.283719 | 0.260403 | 0.305042 | 0.404946 | 0.316802 | 0.408545 | 0.405543 | 0.390557 | 0.333713 | 0.382709 | -0.039962 | -0.048234 | -0.051864 | -0.044558 | -0.045050 |
Attacking_Position | 0.124641 | -0.031746 | 0.043698 | 0.354501 | -0.419544 | -0.344840 | 0.073873 | 0.354699 | 0.719577 | 0.855487 | 0.888391 | 0.089095 | 0.097474 | 0.130957 | 0.371589 | 0.373846 | 1.000000 | 0.146484 | 0.738465 | 0.612847 | 0.771688 | 0.749769 | 0.612211 | 0.666267 | 0.656369 | 0.629698 | -0.002622 | 0.565325 | 0.690857 | 0.116465 | 0.532394 | 0.795237 | 0.880495 | 0.850896 | 0.804621 | 0.727188 | 0.798127 | 0.841600 | -0.665015 | -0.668924 | -0.663450 | -0.664273 | -0.666512 |
Interceptions | -0.154804 | -0.125007 | 0.006995 | 0.319504 | -0.050358 | -0.028947 | 0.192667 | 0.058148 | 0.067407 | 0.392803 | 0.264903 | 0.922118 | 0.915207 | 0.930060 | 0.736112 | 0.318822 | 0.146484 | 1.000000 | 0.180741 | 0.386457 | 0.417610 | 0.516755 | 0.578525 | 0.152006 | 0.170350 | 0.566760 | 0.342730 | 0.138773 | 0.126500 | 0.279615 | 0.536809 | 0.264911 | -0.044888 | 0.181337 | 0.260755 | 0.292869 | 0.104781 | 0.071093 | -0.470613 | -0.474997 | -0.473268 | -0.474025 | -0.474850 |
Vision | 0.076988 | -0.071177 | 0.028113 | 0.489277 | -0.359610 | -0.283098 | 0.189982 | 0.352235 | 0.591623 | 0.732518 | 0.736197 | 0.097899 | 0.108223 | 0.143787 | 0.312152 | 0.482080 | 0.738465 | 0.180741 | 1.000000 | 0.648886 | 0.688579 | 0.728223 | 0.699200 | 0.457209 | 0.431337 | 0.482344 | -0.035903 | 0.476798 | 0.594925 | 0.054090 | 0.305804 | 0.679237 | 0.695177 | 0.754865 | 0.750496 | 0.718754 | 0.647055 | 0.700223 | -0.400721 | -0.405353 | -0.398335 | -0.397728 | -0.401582 |
Composure | -0.016093 | -0.117220 | 0.005840 | 0.613612 | -0.169460 | -0.083541 | 0.355588 | 0.316486 | 0.490854 | 0.704726 | 0.627388 | 0.327939 | 0.314994 | 0.353054 | 0.534981 | 0.589313 | 0.612847 | 0.386457 | 0.648886 | 1.000000 | 0.594509 | 0.704532 | 0.659843 | 0.385533 | 0.391405 | 0.544327 | 0.258847 | 0.329439 | 0.463008 | 0.243641 | 0.542475 | 0.673363 | 0.562688 | 0.642917 | 0.641637 | 0.606544 | 0.590273 | 0.622623 | -0.462405 | -0.470743 | -0.468175 | -0.464087 | -0.469048 |
Crossing | 0.045986 | -0.067383 | 0.012553 | 0.401851 | -0.471327 | -0.389293 | 0.134576 | 0.324117 | 0.644761 | 0.838775 | 0.848864 | 0.384596 | 0.400583 | 0.417381 | 0.476202 | 0.381557 | 0.771688 | 0.417610 | 0.688579 | 0.594509 | 1.000000 | 0.811867 | 0.764061 | 0.650463 | 0.638415 | 0.667137 | -0.032359 | 0.593965 | 0.681712 | 0.117779 | 0.482777 | 0.704200 | 0.644380 | 0.740554 | 0.826872 | 0.761017 | 0.648078 | 0.684915 | -0.658450 | -0.662598 | -0.658385 | -0.658085 | -0.661232 |
Short_Pass | 0.036071 | -0.085123 | 0.034513 | 0.496239 | -0.356768 | -0.299264 | 0.127537 | 0.338919 | 0.628088 | 0.904398 | 0.833578 | 0.476693 | 0.479273 | 0.514137 | 0.597913 | 0.457700 | 0.749769 | 0.516755 | 0.728223 | 0.704532 | 0.811867 | 1.000000 | 0.900749 | 0.558926 | 0.555353 | 0.708465 | 0.118579 | 0.515630 | 0.606182 | 0.174645 | 0.632108 | 0.771737 | 0.653929 | 0.761394 | 0.779465 | 0.742423 | 0.675478 | 0.691174 | -0.714431 | -0.717572 | -0.713856 | -0.714071 | -0.716827 |
Long_Pass | -0.006230 | -0.100525 | 0.016371 | 0.483217 | -0.323575 | -0.261611 | 0.179109 | 0.298103 | 0.515631 | 0.793084 | 0.717857 | 0.535364 | 0.540317 | 0.567442 | 0.583940 | 0.444277 | 0.612211 | 0.578525 | 0.699200 | 0.659843 | 0.764061 | 0.900749 | 1.000000 | 0.443544 | 0.435200 | 0.632998 | 0.108879 | 0.450968 | 0.522242 | 0.141914 | 0.518379 | 0.679311 | 0.507594 | 0.674009 | 0.716427 | 0.710268 | 0.550959 | 0.569566 | -0.595199 | -0.598739 | -0.594084 | -0.594416 | -0.597275 |
Acceleration | 0.079866 | -0.006315 | 0.071003 | 0.206392 | -0.521688 | -0.465558 | -0.175966 | 0.257156 | 0.619623 | 0.669026 | 0.740657 | 0.138092 | 0.159178 | 0.158883 | 0.260563 | 0.183576 | 0.666267 | 0.152006 | 0.457209 | 0.385533 | 0.650463 | 0.558926 | 0.443544 | 1.000000 | 0.922681 | 0.612846 | -0.164064 | 0.681551 | 0.792586 | 0.209320 | 0.345955 | 0.538325 | 0.591831 | 0.571502 | 0.595826 | 0.486247 | 0.522338 | 0.563226 | -0.589681 | -0.589198 | -0.589036 | -0.589799 | -0.588293 |
Speed | 0.056282 | -0.010092 | 0.079394 | 0.224253 | -0.451128 | -0.404240 | -0.168440 | 0.240919 | 0.598727 | 0.665755 | 0.725716 | 0.163242 | 0.181316 | 0.182390 | 0.291840 | 0.188701 | 0.656369 | 0.170350 | 0.431337 | 0.391405 | 0.638415 | 0.555353 | 0.435200 | 0.922681 | 1.000000 | 0.627496 | -0.085941 | 0.619552 | 0.748592 | 0.232382 | 0.398331 | 0.548975 | 0.582587 | 0.558026 | 0.576378 | 0.462375 | 0.515824 | 0.555322 | -0.600348 | -0.599891 | -0.599152 | -0.599809 | -0.599522 |
Stamina | 0.003828 | -0.101258 | 0.053830 | 0.355335 | -0.293564 | -0.241365 | 0.070685 | 0.228619 | 0.469200 | 0.724758 | 0.676495 | 0.538772 | 0.538313 | 0.561885 | 0.643250 | 0.346043 | 0.629698 | 0.566760 | 0.482344 | 0.544327 | 0.667137 | 0.708465 | 0.632998 | 0.612846 | 0.627496 | 1.000000 | 0.230247 | 0.458269 | 0.557333 | 0.331521 | 0.640626 | 0.620266 | 0.495899 | 0.591168 | 0.586883 | 0.537091 | 0.516367 | 0.523170 | -0.702177 | -0.705673 | -0.702016 | -0.703375 | -0.705185 |
Strength | -0.099086 | -0.141140 | -0.012495 | 0.369045 | 0.537223 | 0.613829 | 0.329289 | -0.004841 | -0.117029 | 0.079898 | -0.046376 | 0.327395 | 0.287903 | 0.321261 | 0.450040 | 0.290929 | -0.002622 | 0.342730 | -0.035903 | 0.258847 | -0.032359 | 0.118579 | 0.108879 | -0.164064 | -0.085941 | 0.230247 | 1.000000 | -0.419046 | -0.243772 | 0.268866 | 0.458370 | 0.172875 | -0.012010 | 0.045462 | -0.036263 | -0.003688 | 0.052389 | 0.022775 | -0.079647 | -0.085167 | -0.084113 | -0.080986 | -0.084108 |
Balance | 0.089038 | 0.010762 | 0.046095 | 0.087811 | -0.799775 | -0.680791 | -0.100131 | 0.253466 | 0.542743 | 0.573786 | 0.638638 | 0.117471 | 0.145242 | 0.139473 | 0.172027 | 0.130092 | 0.565325 | 0.138773 | 0.476798 | 0.329439 | 0.593965 | 0.515630 | 0.450968 | 0.681551 | 0.619552 | 0.458269 | -0.419046 | 1.000000 | 0.748228 | 0.167705 | 0.157088 | 0.429301 | 0.486708 | 0.504732 | 0.558874 | 0.493454 | 0.453402 | 0.484856 | -0.484823 | -0.484486 | -0.484118 | -0.487582 | -0.485658 |
Agility | 0.085691 | -0.036128 | 0.047667 | 0.283309 | -0.611198 | -0.535404 | -0.019459 | 0.306049 | 0.637400 | 0.695569 | 0.754705 | 0.085645 | 0.103459 | 0.110567 | 0.239329 | 0.283719 | 0.690857 | 0.126500 | 0.594925 | 0.463008 | 0.681712 | 0.606182 | 0.522242 | 0.792586 | 0.748592 | 0.557333 | -0.243772 | 0.748228 | 1.000000 | 0.208837 | 0.266705 | 0.563776 | 0.627152 | 0.637318 | 0.668396 | 0.577702 | 0.552681 | 0.616572 | -0.507581 | -0.508065 | -0.508568 | -0.506763 | -0.507833 |
Jumping | -0.100935 | -0.106797 | 0.002805 | 0.289840 | -0.063048 | 0.005842 | 0.168694 | 0.064655 | 0.035166 | 0.172802 | 0.117374 | 0.258669 | 0.254936 | 0.255130 | 0.352169 | 0.260403 | 0.116465 | 0.279615 | 0.054090 | 0.243641 | 0.117779 | 0.174645 | 0.141914 | 0.209320 | 0.232382 | 0.331521 | 0.268866 | 0.167705 | 0.208837 | 1.000000 | 0.360225 | 0.170115 | 0.070301 | 0.111898 | 0.087956 | 0.063666 | 0.109438 | 0.102458 | -0.158394 | -0.158524 | -0.161687 | -0.158992 | -0.157636 |
Heading | -0.072020 | -0.076264 | 0.026235 | 0.343265 | 0.005367 | 0.019235 | 0.137785 | 0.190847 | 0.391626 | 0.658111 | 0.548257 | 0.546994 | 0.523946 | 0.555447 | 0.677640 | 0.305042 | 0.532394 | 0.536809 | 0.305804 | 0.542475 | 0.482777 | 0.632108 | 0.518379 | 0.345955 | 0.398331 | 0.640626 | 0.458370 | 0.157088 | 0.266705 | 0.360225 | 1.000000 | 0.619807 | 0.476265 | 0.506579 | 0.451545 | 0.425968 | 0.553426 | 0.502497 | -0.747203 | -0.751930 | -0.747164 | -0.749532 | -0.750380 |
Shot_Power | 0.083610 | -0.051829 | 0.021477 | 0.441773 | -0.273413 | -0.188739 | 0.151174 | 0.334897 | 0.640183 | 0.829902 | 0.795016 | 0.219159 | 0.217468 | 0.256805 | 0.496297 | 0.404946 | 0.795237 | 0.264911 | 0.679237 | 0.673363 | 0.704200 | 0.771737 | 0.679311 | 0.538325 | 0.548975 | 0.620266 | 0.172875 | 0.429301 | 0.563776 | 0.170115 | 0.619807 | 1.000000 | 0.797201 | 0.880013 | 0.784935 | 0.749059 | 0.786514 | 0.817316 | -0.650511 | -0.652568 | -0.648162 | -0.649521 | -0.651392 |
Finishing | 0.138914 | -0.007898 | 0.032341 | 0.328576 | -0.347154 | -0.281775 | 0.064487 | 0.361983 | 0.715228 | 0.781218 | 0.817034 | -0.096066 | -0.098796 | -0.058670 | 0.230695 | 0.316802 | 0.880495 | -0.044888 | 0.695177 | 0.562688 | 0.644380 | 0.653929 | 0.507594 | 0.591831 | 0.582587 | 0.495899 | -0.012010 | 0.486708 | 0.627152 | 0.070301 | 0.476265 | 0.797201 | 1.000000 | 0.863186 | 0.750697 | 0.687716 | 0.834705 | 0.876136 | -0.573674 | -0.576028 | -0.571200 | -0.571792 | -0.573409 |
Long_Shots | 0.109168 | -0.040658 | 0.028781 | 0.419517 | -0.364182 | -0.274446 | 0.149635 | 0.365637 | 0.680434 | 0.831846 | 0.836080 | 0.116621 | 0.117163 | 0.156849 | 0.386260 | 0.408545 | 0.850896 | 0.181337 | 0.754865 | 0.642917 | 0.740554 | 0.761394 | 0.674009 | 0.571502 | 0.558026 | 0.591168 | 0.045462 | 0.504732 | 0.637318 | 0.111898 | 0.506579 | 0.880013 | 0.863186 | 1.000000 | 0.830707 | 0.801342 | 0.806805 | 0.857302 | -0.597866 | -0.601603 | -0.595864 | -0.597474 | -0.598692 |
Curve | 0.081888 | -0.053631 | 0.010840 | 0.420796 | -0.423115 | -0.343380 | 0.139101 | 0.359044 | 0.689265 | 0.832009 | 0.840061 | 0.206493 | 0.216875 | 0.247088 | 0.395877 | 0.405543 | 0.804621 | 0.260755 | 0.750496 | 0.641637 | 0.826872 | 0.779465 | 0.716427 | 0.595826 | 0.576378 | 0.586883 | -0.036263 | 0.558874 | 0.668396 | 0.087956 | 0.451545 | 0.784935 | 0.750697 | 0.830707 | 1.000000 | 0.856065 | 0.750694 | 0.799441 | -0.604127 | -0.606164 | -0.601059 | -0.601801 | -0.603812 |
Freekick_Accuracy | 0.106621 | -0.062077 | 0.007001 | 0.399575 | -0.380217 | -0.293956 | 0.195338 | 0.345745 | 0.634867 | 0.763315 | 0.750014 | 0.233461 | 0.241188 | 0.274715 | 0.402368 | 0.390557 | 0.727188 | 0.292869 | 0.718754 | 0.606544 | 0.761017 | 0.742423 | 0.710268 | 0.486247 | 0.462375 | 0.537091 | -0.003688 | 0.493454 | 0.577702 | 0.063666 | 0.425968 | 0.749059 | 0.687716 | 0.801342 | 0.856065 | 1.000000 | 0.732686 | 0.737697 | -0.557384 | -0.559510 | -0.554188 | -0.554871 | -0.557189 |
Penalties | 0.095289 | -0.016220 | 0.020878 | 0.339898 | -0.321246 | -0.246189 | 0.131469 | 0.340757 | 0.662108 | 0.767803 | 0.765259 | 0.062951 | 0.059355 | 0.096483 | 0.329841 | 0.333713 | 0.798127 | 0.104781 | 0.647055 | 0.590273 | 0.648078 | 0.675478 | 0.550959 | 0.522338 | 0.515824 | 0.516367 | 0.052389 | 0.453402 | 0.552681 | 0.109438 | 0.553426 | 0.786514 | 0.834705 | 0.806805 | 0.750694 | 0.732686 | 1.000000 | 0.816956 | -0.612528 | -0.614877 | -0.609397 | -0.611300 | -0.613301 |
Volleys | 0.117381 | -0.020482 | 0.025120 | 0.386494 | -0.333576 | -0.258932 | 0.133950 | 0.366610 | 0.701017 | 0.789287 | 0.804633 | 0.013556 | 0.015133 | 0.053435 | 0.318366 | 0.382709 | 0.841600 | 0.071093 | 0.700223 | 0.622623 | 0.684915 | 0.691174 | 0.569566 | 0.563226 | 0.555322 | 0.523170 | 0.022775 | 0.484856 | 0.616572 | 0.102458 | 0.502497 | 0.817316 | 0.876136 | 0.857302 | 0.799441 | 0.737697 | 0.816956 | 1.000000 | -0.576643 | -0.579607 | -0.574444 | -0.574602 | -0.576507 |
GK_Positioning | -0.031492 | 0.004684 | -0.027994 | -0.018586 | 0.358795 | 0.342502 | 0.122371 | -0.232109 | -0.607676 | -0.776117 | -0.741793 | -0.492932 | -0.498386 | -0.521127 | -0.561675 | -0.039962 | -0.665015 | -0.470613 | -0.400721 | -0.462405 | -0.658450 | -0.714431 | -0.595199 | -0.589681 | -0.600348 | -0.702177 | -0.079647 | -0.484823 | -0.507581 | -0.158394 | -0.747203 | -0.650511 | -0.573674 | -0.597866 | -0.604127 | -0.557384 | -0.612528 | -0.576643 | 1.000000 | 0.968213 | 0.962937 | 0.968031 | 0.968550 |
GK_Diving | -0.012435 | 0.011290 | -0.026117 | -0.027615 | 0.357683 | 0.340775 | 0.105158 | -0.236372 | -0.610500 | -0.779922 | -0.743848 | -0.496354 | -0.501643 | -0.524291 | -0.567497 | -0.048234 | -0.668924 | -0.474997 | -0.405353 | -0.470743 | -0.662598 | -0.717572 | -0.598739 | -0.589198 | -0.599891 | -0.705673 | -0.085167 | -0.484486 | -0.508065 | -0.158524 | -0.751930 | -0.652568 | -0.576028 | -0.601603 | -0.606164 | -0.559510 | -0.614877 | -0.579607 | 0.968213 | 1.000000 | 0.963512 | 0.968287 | 0.972519 |
GK_Kicking | -0.015472 | 0.008788 | -0.023273 | -0.031696 | 0.356070 | 0.339505 | 0.109931 | -0.230924 | -0.605746 | -0.775690 | -0.739995 | -0.495732 | -0.501019 | -0.523387 | -0.563989 | -0.051864 | -0.663450 | -0.473268 | -0.398335 | -0.468175 | -0.658385 | -0.713856 | -0.594084 | -0.589036 | -0.599152 | -0.702016 | -0.084113 | -0.484118 | -0.508568 | -0.161687 | -0.747164 | -0.648162 | -0.571200 | -0.595864 | -0.601059 | -0.554188 | -0.609397 | -0.574444 | 0.962937 | 0.963512 | 1.000000 | 0.963264 | 0.964500 |
GK_Handling | -0.024611 | 0.006725 | -0.023064 | -0.021343 | 0.359746 | 0.341829 | 0.113216 | -0.233080 | -0.606713 | -0.775632 | -0.740616 | -0.496431 | -0.501429 | -0.523648 | -0.564734 | -0.044558 | -0.664273 | -0.474025 | -0.397728 | -0.464087 | -0.658085 | -0.714071 | -0.594416 | -0.589799 | -0.599809 | -0.703375 | -0.080986 | -0.487582 | -0.506763 | -0.158992 | -0.749532 | -0.649521 | -0.571792 | -0.597474 | -0.601801 | -0.554871 | -0.611300 | -0.574602 | 0.968031 | 0.968287 | 0.963264 | 1.000000 | 0.968501 |
GK_Reflexes | -0.018816 | 0.007480 | -0.024923 | -0.022978 | 0.360260 | 0.341785 | 0.106979 | -0.235275 | -0.609282 | -0.777668 | -0.742065 | -0.497013 | -0.501738 | -0.524598 | -0.566184 | -0.045050 | -0.666512 | -0.474850 | -0.401582 | -0.469048 | -0.661232 | -0.716827 | -0.597275 | -0.588293 | -0.599522 | -0.705185 | -0.084108 | -0.485658 | -0.507833 | -0.157636 | -0.750380 | -0.651392 | -0.573409 | -0.598692 | -0.603812 | -0.557189 | -0.613301 | -0.576507 | 0.968550 | 0.972519 | 0.964500 | 0.968501 | 1.000000 |
g = data.groupby("Club_Position")
g["GK_Handling"].mean().sort_values(ascending=False).plot(kind="bar")
Out[85]:
data["Age"].head(3)
Out[90]:
0 32
1 29
2 25
Name: Age, dtype: int64
t = data.copy()
# data.plot(kind="scatter", x="Age", y="Rating")
# 将连续值切分为离散值。bins指定区间的数量(桶的数量)。这里的区间界限与直方图不同。
# 直方图的区间界限是前闭后开,最后一个区间双闭,而cut产生的区间,是前开后闭的。
# t["Age"] = pd.cut(t["Age"], bins=3)
# bins如果提供一个整数,表示区间的数量,此时会根据数据范围,进行等分区间。如果需要不等分区间,
# 可以传递一个数组,显式指定区间范围。
# cut方法默认情况下,会使用区间来作为区分之后的值,该值可能不够友好,我们也可以通过labels参数
# 指定切分之后的显示内容。
t["Age"] = pd.cut(t["Age"], bins=[1, 20, 30, 40, 100], labels=["弱冠之年", "而立之年", "不惑之年", "垂暮之年"])
g = t.groupby("Age")
g["Rating"].mean().plot(kind="line", marker="o", xticks=[0, 1, 2, 3])
Out[101]: