<jupyter_start><jupyter_text>___ ___ Ecommerce Purchases ExerciseIn this Exercise you will be given some Fake Data about some purchases done through Amazon! Just go ahead and follow the directions and try your best to answer the questions and complete the tasks. Feel free to reference the solutions. Most of the tasks can be solved in different ways. For the most part, the questions get progressively harder.Please excuse anything that doesn't make "Real-World" sense in the dataframe, all the data is fake and made-up.Also note that all of these questions can be answered with one line of code.____** Import pandas and read in the Ecommerce Purchases csv file and set it to a DataFrame called ecom. **<jupyter_code>import pandas as pd 
data = pd.read_csv("Ecommerce Purchases")
df= pd.DataFrame(data)<jupyter_output><empty_output><jupyter_text>**Check the head of the DataFrame.**<jupyter_code>df.head()<jupyter_output><empty_output><jupyter_text>** How many rows and columns are there? **<jupyter_code>df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 10000 entries, 0 to 9999
Data columns (total 14 columns):
Address             10000 non-null object
Lot                 10000 non-null object
AM or PM            10000 non-null object
Browser Info        10000 non-null object
Company             10000 non-null object
Credit Card         10000 non-null int64
CC Exp Date         10000 non-null object
CC Security Code    10000 non-null int64
CC Provider         10000 non-null object
Email               10000 non-null object
Job                 10000 non-null object
IP Address          10000 non-null object
Language            10000 non-null object
Purchase Price      10000 non-null float64
dtypes: float64(1), int64(2), object(11)
memory usage: 1.1+ MB<jupyter_text>** What is the average Purchase Price? **<jupyter_code>#50.34730200000025
df["Purchase Price"].mean()<jupyter_output><empty_output><jupyter_text>** What were the highest and lowest purchase prices? **<jupyter_code>df["Purchase Price"].max()
df["Purchase Price"].min()<jupyter_output><empty_output><jupyter_text>** How many people have English 'en' as their Language of choice on the website? **<jupyter_code>'''Address             1098
Lot                 1098
AM or PM            1098
Browser Info        1098
Company             1098
Credit Card         1098
CC Exp Date         1098
CC Security Code    1098
CC Provider         1098
Email               1098
Job                 1098
IP Address          1098
Language            1098
Purchase Price      1098
dtype: int64'''
i = 0 
df[df["Language"]=="en"].count()<jupyter_output><empty_output><jupyter_text>** How many people have the job title of "Lawyer" ? **<jupyter_code>'''
<class 'pandas.core.frame.DataFrame'>
Int64Index: 30 entries, 470 to 9979
Data columns (total 14 columns):
Address             30 non-null object
Lot                 30 non-null object
AM or PM            30 non-null object
Browser Info        30 non-null object
Company             30 non-null object
Credit Card         30 non-null int64
CC Exp Date         30 non-null object
CC Security Code    30 non-null int64
CC Provider         30 non-null object
Email               30 non-null object
Job                 30 non-null object
IP Address          30 non-null object
Language            30 non-null object
Purchase Price      30 non-null float64
dtypes: float64(1), int64(2), object(11)
memory usage: 3.5+ KB

'''
df[df["Job"]=="Lawyer"].info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Int64Index: 30 entries, 470 to 9979
Data columns (total 14 columns):
Address             30 non-null object
Lot                 30 non-null object
AM or PM            30 non-null object
Browser Info        30 non-null object
Company             30 non-null object
Credit Card         30 non-null int64
CC Exp Date         30 non-null object
CC Security Code    30 non-null int64
CC Provider         30 non-null object
Email               30 non-null object
Job                 30 non-null object
IP Address          30 non-null object
Language            30 non-null object
Purchase Price      30 non-null float64
dtypes: float64(1), int64(2), object(11)
memory usage: 3.5+ KB<jupyter_text>** How many people made the purchase during the AM and how many people made the purchase during PM ? ****(Hint: Check out [value_counts()](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.value_counts.html) ) **<jupyter_code>df["AM or PM"].value_counts()<jupyter_output><empty_output><jupyter_text>** What are the 5 most common Job Titles? **<jupyter_code>df["Job"].value_counts().head(5)<jupyter_output><empty_output><jupyter_text>** Someone made a purchase that came from Lot: "90 WT" , what was the Purchase Price for this transaction? **<jupyter_code>'''513    75.1
Name: Purchase Price, dtype: float64'''
df[df["Lot"]=="90 WT"]["Purchase Price"]<jupyter_output><empty_output><jupyter_text>** What is the email of the person with the following Credit Card Number: 4926535242672853 **<jupyter_code>'''1234    <EMAIL>
Name: Email, dtype: object'''
df
df[df["Credit Card"]==4926535242672853]["Email"]<jupyter_output><empty_output><jupyter_text>** How many people have American Express as their Credit Card Provider *and* made a purchase above $95 ?**<jupyter_code>'''Address             39
Lot                 39
AM or PM            39
Browser Info        39
Company             39
Credit Card         39
CC Exp Date         39
CC Security Code    39
CC Provider         39
Email               39
Job                 39
IP Address          39
Language            39
Purchase Price      39
dtype: int64

'''
df
df[(df["Purchase Price"]>95)&(df["CC Provider"]=="American Express")].count()<jupyter_output><empty_output><jupyter_text>** Hard: How many people have a credit card that expires in 2025? **<jupyter_code>#1033
sum(df["CC Exp Date"].apply(lambda x : "25" in x))<jupyter_output><empty_output><jupyter_text>** Hard: What are the top 5 most popular email providers/hosts (e.g. gmail.com, yahoo.com, etc...) **<jupyter_code>df["Email"].apply(lambda email : email.split("@")[1]).value_counts().head(5)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09155613070203818, 'fraction_numerical': 0.06211582012293756, 'mean_word_length': 3.1330213903743314, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 60, 'https://': 0, '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': '14', 'dir': 'jupyter-structured-clean-dedup', 'id': '650056', 'license': 'MIT', 'n_tokens_mistral': 2093, 'n_tokens_neox': 1813, 'n_words': 671, 'path': 'Pandas/03-Ecommerce Purchases Exercise .ipynb', 'repo_name': 'DEKKAR-AHMED/data_Science_Learning', 'size': '6203'}