kag_sal_ecom Flashcards
For DataFrame ‘sal’, find out how many entries there are
sal.info()
What is the average BasePay?
sal[‘BasePay’].mean()
What is the highest amount of OvertimePay in the dataset?
sal[‘OvertimePay’].max()
Return the entire record for the highest amount of OvertimePay in the dataset
sal[sal[‘OvertimePay’]==sal[‘OvetimePay’].max()]
Return just the name of the employee with the highest amount of OvertimPay in the dataset
sal[sal[‘OvertimePay’]==sal[‘OvertimePay’].max()][‘EmployeeName’]
Return the JobTitle of employee JOSEPH DRISCOLL
sal[sal[‘EmployeeName’]==’JOESEPH DRISCOLL’][‘JobTitle’]
Return the TotalPayBenefits for employee JOSEPH DRISCOLL
sal[sal[‘EmployeeName’]==’JOSEPH DRISCOLL’][‘TotalPayBenefits’]
Return the record of the person with the lowest TotalPayBenefits
sal[sal[‘TotalPayBenefits’]==sal[‘TotalPayBenefits’].min()]
Return just the name of the employee with the lowest TotalPayBenefits
sal[sal[‘TotalPayBenefits’]==sal[‘TotalPayBenefits’].min()][‘EmployeeName’]
What is the average (mean) BasePay of all employees per year?
sal.groupby(‘Year’).mean()[‘BasePay’]
How many unique job titles are there?
sal[‘JobTitle’].nunique()
What are the top 5 most common job titles?
sal[‘JobTitle’].value_counts().head(5)
How many job title were represented by only 1 person in 2013?
sal[sal[‘Year’]==2013][‘JobTitle’].value_counts() == 1).sum()
How many people have the word chief in their job title?
def chief_string(title): if 'chief' in title.lower(): return True else: return False
(sal[‘JobTitle’].apply(lambda x: chief_string(x))).sum()
How do you determine if there is correlation between length of Job Title string and TotalPayBenefits?
sal[‘title_len’] = sal[‘JobTitle’].apply(len)
sal[[‘title_len’, ‘TotalPayBenefits’]].corr()
What is the average Purchase Price (ecom)
ecom[‘Purchase Price’].mean()
What are the highest and lowest Purchase Prices?
ecom[‘Purchase Price’].max()
ecom[‘Purchase Price’].min()
How many people have ‘en’ as their Language of choice on the website?
ecom[ecom[‘Language’]==’en’].count()
How many people have the Job ‘Lawyer’?
ecom[ecom[‘Job’]==’Lawyer’].count()
How many people made the puchase during the AM and how many made the purchase during the PM? (‘AM or PM’)
ecom[ecom[‘AM or PM’].value_counts()
What are the 5 most common Job titles?
ecom[‘Job’].value_counts().head(5)
Someone made a purchase that came from Lot “90 WT”. What was the Purchase Price for this transaction?
ecom[ecom[‘Lot’]==’90 WT’][‘Purchase Price’]
What is the email address of the person with the following CC Number? 4926535242672853
ecom[ecom[‘CC Number’]==4926535242672853][‘Email’]
How many people have American Express as their CC Provider and made a purchase above $95?
ecom[(ecom[‘CC Provider’]==’American Express’) & (ecom[‘Purchase Price’]>95)].count()
How many people have a CC Exp Date of 2025?
sum(ecom[‘CC Exp Date’].apply(lambda x: x[3:]) == ‘25’)
What are the top 5 most popular email providers/hosts?
ecom[‘Email’].apply(lambda x: x.split(‘@’)[1]).value_counts().head(5)