Untitled
unknown
python
3 years ago
1.8 kB
4
Indexable
# coding: utf-8
# # 1. Import pandas and Numpy
# In[1]:
import pandas as pd
import numpy as np
# # 2. Read Csv from file
# In[ ]:
ecom=pd.read_csv('Ecommerce Purchases.csv')
# # Display csv
# In[7]:
ecom
# # How many rows and columns are there
# In[8]:
ecom.info()
# # 3. Check the head of the dataframe
# In[9]:
ecom.head()
# # Check the tail of the dataframne
# In[10]:
ecom.tail()
# # What is the average purchase price
# In[11]:
ecom['Purchase Price'].mean()
# # Highest purchase price
# In[12]:
ecom['Purchase Price'].max()
# # Lowest purchase price
# In[13]:
ecom['Purchase Price'].min()
# # How many people have english as their language of choice on the website
# In[15]:
ecom[ecom['Language']=='en'].count()
# # How many people have job title of lawyer
# In[16]:
ecom[ecom['Job']=='Lawyer'].info()
# # How many people made the purchase during the AM and how many people made the purchase during PM?
# In[27]:
ecom['AM or PM'].value_counts()
# # What are the five most common job title
# In[20]:
ecom['Job'].value_counts().head(5)
# # Someone made a purchase that came from Lot: "90 WT", What was the purchase price for this transaction
# In[21]:
ecom[ecom['Lot']=='90 WT']['Purchase Price']
# # What is the Email of the person With the following Credit card number
# In[23]:
ecom[ecom['Credit Card']==4926535242672853]['Email']
# # How many people have American Express as their Credit Card Provider and made a purchase above $95
# In[26]:
ecom[(ecom['CC Provider']=='American Express') & (ecom['Purchase Price']>95)].count()
# # How many people have a credit card that expires in year 2025
# In[31]:
sum(ecom['CC Exp Date'].apply(lambda x: x[3:]) =='25')
Editor is loading...