"""
I tried to visualize and analyze data.

According to the result; while the team with the most transfer was [Inter](#7), the team that spent the most money on transfer was [Chelsea](#6)...

[Ronaldo](#3) was determined as the most efficient striker.

<font color = 'black'>

* [Load and Visualizing the Dataset](#1)
* [Amateur Football Players](#2)
* [Most Effective and Valuable Striker](#3)
* [Highest Market Value and Transfer Fee](#4)
* [The club that spends the most money according to the transfers](#5)
* [Result](#6)
"""
import numpy as np 
import pandas as pd 
import matplotlib.pyplot as plt
import seaborn as sns  
import os
import warnings
warnings.filterwarnings("ignore")
for dirname, _, filenames in os.walk('/kaggle/input'):
    for filename in filenames:
        print(os.path.join(dirname, filename))
"""
<a id = "1"></a><br>
# Load and Visualizing the Dataset
"""
Data = pd.read_csv('../input/top-250-football-transfers-from-2000-to-2018/top250-00-19.csv')
Data.head()

Data.info()
Data.corr()
# Name of columns

Data.columns
Data.Age.plot(kind = 'line', color = 'b',label = 'Age',linewidth = 1.5,alpha = 0.8, grid = True, linestyle = ':')
Data.Market_value.plot(color = 'r',label = 'Market_value',linewidth = 1.5, alpha = 0.5, grid = True, linestyle = '-.')
Data.Transfer_fee.plot(kind = 'line', color = 'k', label = 'Transfer_fee', linewidth = 1.5, alpha = 0.5, grid = True, linestyle = '--')
plt.legend(loc='best')    
plt.xlabel('x axis')              
plt.ylabel('y axis')
plt.title('Line Plot')
plt.show()
Data.plot(kind='scatter', x='Age', y='Market_value',alpha = 0.5,color = 'green')
plt.xlabel('Age')              
plt.ylabel('Market Value')
plt.title('Age and Market Value Scatter Plot')  
sns.jointplot(data=Data, x="Age", y="Transfer_fee", marker="+", s=100, marginal_kws=dict(bins=25, fill=False))
Comp = sns.cubehelix_palette(3, rot=-.5, dark=.2)
sns.violinplot(data=Data, palette=Comp, inner="points")
plt.show()
sns.swarmplot(x="Age", y="Market_value", data=Data)
plt.show()
sns.set(style = "white")
df = Data.loc[:,["Age","Market_value","Transfer_fee"]]
g = sns.PairGrid(df,diag_sharey = False,)
g.map_lower(sns.kdeplot,cmap="Blues_d")
g.map_upper(plt.scatter)
g.map_diag(sns.kdeplot,lw =3)
plt.show()
"""
<a id = "2"></a><br>
# Amateur Football Players
"""
x = Data['Age']<18
Data[x]
"""
<a id = "3"></a><br>
# **Most Effective and Valuable Striker**
"""
"""
* According to the [article](https://www.tandfonline.com/doi/full/10.1080/24748668.2020.1833625), a striker's most effective age is between the ages of **21 and 25**. For this, we will consider the strikers in this age range.
"""
PlayerAge = Data[np.logical_and(Data['Age']>21, Data['Age']<25)]
PlayerAge
PlayerPosition = PlayerAge[['Name', 'Position', 'Age', 'Market_value', 'Transfer_fee']]
PlayerPosition
EfficientStriker = PlayerPosition.loc[PlayerPosition['Position'] == 'Centre-Forward']
EfficientStriker
NameofStriker = EfficientStriker[['Name', 'Market_value', 'Transfer_fee']]
NameofStriker
PlayerWorth = NameofStriker.loc[NameofStriker['Market_value'].idxmax()]
PlayerWorth
PlayerFee = NameofStriker.loc[NameofStriker['Transfer_fee'].idxmax()]
PlayerFee
"""
**Teams Cristiano Ronaldo Played with During This Time**
"""
Data.loc[Data['Name'] == 'Cristiano Ronaldo']
"""
<a id = "4"></a><br>
# **Highest Market Value and Transfer Fee**
"""
Data.loc[Data['Market_value'].idxmax()]

Data.loc[Data['Transfer_fee'].idxmax()]
"""
<a id = "5"></a><br>
# **The club that spends the most money according to the transfers**
"""
RichClubs = Data[['Team_to', 'Transfer_fee']]
RichClubs
Top = RichClubs.groupby(['Team_to', 'Transfer_fee']).size()
Top.head(40)
"""
<a id = "7"></a><br>
* **Team with the most transfers**
"""
f, ax = plt.subplots(figsize=(10,10))
RichClubGraph = RichClubs['Team_to'].value_counts()[:30].sort_values(ascending=True).plot(kind='barh', ax=ax, legend = False, color = 'y', edgecolor='r', width=0.7)
plt.tight_layout()
RichClubs['Team_to'].value_counts()
dff = RichClubs.groupby(["Team_to"]).Transfer_fee.sum().reset_index()
dff = dff.sort_values(by = 'Transfer_fee', ascending=False, na_position='first')

print(dff.head(10))
"""
<a id = "6"></a><br>
**The team that spent the most during this time**
"""
dff.loc[dff['Transfer_fee'].idxmax()]
"""
**[Thank you :)](http://www.galatasaray.org/en/Homepage)** 
"""