<jupyter_start><jupyter_text>Seaborn Source:  [https://github.com/d-insight/code-bank.git](https://github.com/d-insight/code-bank.git)  License: [MIT License](https://opensource.org/licenses/MIT). See open source [license](LICENSE) in the Code Bank repository.  ---  IntroductionSeaborn, is a powerful but easy-to-use data visualization tool! Some examples of charts:![tut1_plots_you_make](https://i.imgur.com/54BoIBW.png)  Set up the notebookThere are a few lines of code that you'll need to run at the top of every notebook to set up your coding environment.  It's not important to understand these lines of code now, and so we won't go into the details just yet.  (_Notice that it returns as output: `Setup Complete`._)<jupyter_code>import pandas as pd
pd.plotting.register_matplotlib_converters()
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
print("Setup Complete")<jupyter_output>Setup Complete<jupyter_text>Load the dataIn this notebook, we'll work with a dataset of historical FIFA rankings and look at six countries: Argentina (ARG), Brazil (BRA), Spain (ESP), France (FRA), Germany (GER), and Italy (ITA).  The dataset is stored as a CSV file.To load the data into the notebook, we'll use two distinct steps, implemented in the code cell below as follows:- begin by specifying the location (or filepath) where the dataset can be accessed- use the filepath to load the contents of the dataset into a Pandas datarframe<jupyter_code># Path of the file to read
fifa_filepath = "data/fifa_ranking.csv"

# Read the file into a variable fifa_data
fifa_data = pd.read_csv(fifa_filepath, parse_dates=True)
# Let's look at the file
fifa_data.head()
# Let's keep only necessary variables
countries = ['ARG', 'BRA', 'ESP', 'FRA', 'GER', 'ITA']
cols = ['rank', 'country_full', 'rank_date']
fifa = fifa_data[fifa_data['country_abrv'].isin(countries)][cols]
fifa<jupyter_output><empty_output><jupyter_text>Transform the dataWe need an appropriate format.<jupyter_code># set rank date as index
fifa.set_index('rank_date', inplace=True)
# from long to wide format
# Check-out this reference for pivoting: https://chrisalbon.com/python/data_wrangling/pandas_long_to_wide/
fifa_pivot = fifa.pivot(columns='country_full', values='rank')
fifa_pivot.to_pickle('fifa_cl')<jupyter_output><empty_output><jupyter_text>Plot the dataIn one line of code!<jupyter_code># Set the width and height of the figure
plt.figure(figsize=(16,6))

# Add title
plt.title("FIFA Ranking")

# Line chart showing how FIFA rankings evolved over time 
sns.lineplot(data=fifa_pivot)<jupyter_output><empty_output><jupyter_text>Plot a subset of the data<jupyter_code>list(fifa_pivot.columns)<jupyter_output><empty_output><jupyter_text>In the next code cell, we plot the lines corresponding to the first two columns in the dataset.<jupyter_code># Set the width and height of the figure
plt.figure(figsize=(14,6))
# Rotate X labels
plt.xticks(rotation=80)

# Add title
plt.title("South America FIFA Rankings")

# Add label for horizontal axis
plt.xlabel("Date")

# Line chart showing Argentina ranking overtime
plotARG = sns.lineplot(data=fifa_pivot['Argentina'], label="Argentina")

# Line chart showing Brazil ranking overtime
plotBRA = sns.lineplot(data=fifa_pivot['Brazil'], label="Brazil")


# Make X labels readable
for ind, label in enumerate(plotARG.get_xticklabels()):
    if ind % 10 == 0:  # every 10th label is kept
        label.set_visible(True)
    else:
        label.set_visible(False)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup