<jupyter_start><jupyter_text>Online Retails Purchase  Introduction: Step 1. Import the necessary libraries<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt<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('Online_Retail.csv',encoding='latin1')
online_rt.head()<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>new = online_rt.loc[online_rt['Country'] != 'United Kingdom']. groupby('Country')['Quantity'].sum().sort_values(ascending = False)[0:11]<jupyter_output><empty_output><jupyter_text>Step 5.  Exclude negative Quatity entries<jupyter_code>step5 = online_rt[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<jupyter_code># groupby CustomerID
customers = online_rt.groupby(['CustomerID','Country']).sum()

# there is an outlier with negative price
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)

customers<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10886571056062581, 'fraction_numerical': 0.013689700130378096, 'mean_word_length': 7.82183908045977, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 1, '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': '91355', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 522, 'n_tokens_neox': 497, 'n_words': 120, 'path': '07_Visualization/Online_Retail/Exercises.ipynb', 'repo_name': 'duongv/pandas_exercises', 'size': '1534'}