Importing Libraries

Setup Complete


Importing Dataset and Data Preparation

rank country_full country_abrv total_points previous_points rank_change cur_year_avg cur_year_avg_weighted last_year_avg last_year_avg_weighted two_year_ago_avg two_year_ago_weighted three_year_ago_avg three_year_ago_weighted confederation
rank_date
1993-08-08 1 Germany GER 0.0 57 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 UEFA
1993-08-08 2 Italy ITA 0.0 57 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 UEFA
1993-08-08 3 Switzerland SUI 0.0 50 9 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 UEFA
1993-08-08 4 Sweden SWE 0.0 55 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 UEFA
1993-08-08 5 Argentina ARG 0.0 51 5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 CONMEBOL
ARG BRA FRA GER ITA ESP
rank_date
1993-08-08 5 8 12 1 2 13
1993-09-23 12 1 7 5 2 14
1993-10-22 9 1 14 4 3 7
1993-11-19 9 4 15 3 1 7
1993-12-23 8 3 15 1 2 5


Data Visualization

Hello, Seaborn



Line Charts



Bar Chart



Heatmap



Scatter Plots



Distributions



Histograms


Say we would like to create a histogram to see how petal length varies in iris flowers. We can do this with the sns.distplot command.

We customize the behavior of the command with two additional pieces of information:

a= chooses the column we'd like to plot (in this case, we chose 'Petal Length (cm)').

kde=False is something we'll always provide when creating a histogram, as leaving it out will create a slightly different plot.



Density plots


The next type of plot is a kernel density estimate (KDE) plot. In case you're not familiar with KDE plots, you can think of it as a smoothed histogram.

To make a KDE plot, we use the sns.kdeplot command. Setting shade=True colors the area below the curve (and data= has identical functionality as when we made the histogram above).



2D KDE plots


We're not restricted to a single column when creating a KDE plot. We can create a two-dimensional (2D) KDE plot with the sns.jointplot command.

In the plot below, the color-coding shows us how likely we are to see different combinations of sepal width and petal length, where darker parts of the figure are more likely.



Color-coded plots


For the next part of the tutorial, we'll create plots to understand differences between the species. To accomplish this, we begin by breaking the dataset into three separate files, with one for each species.

In this case, the legend does not automatically appear on the plot. To force it to show (for any plot type), we can always use plt.legend().



Changing Styles with Seaborn