<jupyter_start><jupyter_text>Online Retails Purchase  Introduction: Step 1. Import the necessary libraries<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

%matplotlib inline<jupyter_output><empty_output><jupyter_text>Step 2. Import the dataset from this [address](https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/07_Visualization/Online_Retail/Online_Retail.csv).   Step 3. Assign it to a variable called online_rtNote: if you receive a utf-8 decode error, set `encoding = 'latin1'` in `pd.read_csv()`.<jupyter_code>online_rt = pd.read_csv('https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/07_Visualization/Online_Retail/Online_Retail.csv', encoding='latin1')<jupyter_output><empty_output><jupyter_text>Step 4. Create a histogram with the 10 countries that have the most 'Quantity' ordered except UK<jupyter_code>hist_df = online_rt.groupby('Country')['Quantity'].sum().sort_values(ascending=False)
hist_df.iloc[1:11].plot(kind='bar')<jupyter_output><empty_output><jupyter_text>Step 5.  Exclude negative Quantity entries<jupyter_code>online_rt = online_rt.loc[online_rt.Quantity > 0]<jupyter_output><empty_output><jupyter_text>Step 6. Create a scatterplot with the Quantity per UnitPrice by CustomerID for the top 3 Countries (except UK)<jupyter_code>customers = online_rt.groupby(['CustomerID','Country']).sum()

customers = customers[customers.UnitPrice > 0]

# get the value of the index and put in the column Country
customers['Country'] = customers.index.get_level_values(1)

# top three countries
top_countries =  ['Netherlands', 'EIRE', 'Germany']

# filter the dataframe to just select ones in the top_countries
customers = customers[customers['Country'].isin(top_countries)]

#################
# Graph Section #
#################

# creates the FaceGrid
g = sns.FacetGrid(customers, col="Country")

# map over a make a scatterplot
g.map(plt.scatter, "Quantity", "UnitPrice", alpha=1)

# adds legend
g.add_legend()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12432959531935642, 'fraction_numerical': 0.01121404193076548, 'mean_word_length': 7.375510204081633, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '318859', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 705, 'n_tokens_neox': 672, 'n_words': 158, 'path': '07_Visualization/Online_Retail/Exercises.ipynb', 'repo_name': 'mtodisco10/pandas_exercises', 'size': '2051'}