kag_sal_ecom Flashcards

1
Q

For DataFrame ‘sal’, find out how many entries there are

A

sal.info()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the average BasePay?

A

sal[‘BasePay’].mean()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the highest amount of OvertimePay in the dataset?

A

sal[‘OvertimePay’].max()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Return the entire record for the highest amount of OvertimePay in the dataset

A

sal[sal[‘OvertimePay’]==sal[‘OvetimePay’].max()]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Return just the name of the employee with the highest amount of OvertimPay in the dataset

A

sal[sal[‘OvertimePay’]==sal[‘OvertimePay’].max()][‘EmployeeName’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Return the JobTitle of employee JOSEPH DRISCOLL

A

sal[sal[‘EmployeeName’]==’JOESEPH DRISCOLL’][‘JobTitle’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Return the TotalPayBenefits for employee JOSEPH DRISCOLL

A

sal[sal[‘EmployeeName’]==’JOSEPH DRISCOLL’][‘TotalPayBenefits’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Return the record of the person with the lowest TotalPayBenefits

A

sal[sal[‘TotalPayBenefits’]==sal[‘TotalPayBenefits’].min()]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Return just the name of the employee with the lowest TotalPayBenefits

A

sal[sal[‘TotalPayBenefits’]==sal[‘TotalPayBenefits’].min()][‘EmployeeName’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the average (mean) BasePay of all employees per year?

A

sal.groupby(‘Year’).mean()[‘BasePay’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How many unique job titles are there?

A

sal[‘JobTitle’].nunique()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the top 5 most common job titles?

A

sal[‘JobTitle’].value_counts().head(5)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How many job title were represented by only 1 person in 2013?

A

sal[sal[‘Year’]==2013][‘JobTitle’].value_counts() == 1).sum()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How many people have the word chief in their job title?

A
def chief_string(title):
    if 'chief' in title.lower():
        return True
    else:
        return False

(sal[‘JobTitle’].apply(lambda x: chief_string(x))).sum()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you determine if there is correlation between length of Job Title string and TotalPayBenefits?

A

sal[‘title_len’] = sal[‘JobTitle’].apply(len)

sal[[‘title_len’, ‘TotalPayBenefits’]].corr()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the average Purchase Price (ecom)

A

ecom[‘Purchase Price’].mean()

17
Q

What are the highest and lowest Purchase Prices?

A

ecom[‘Purchase Price’].max()

ecom[‘Purchase Price’].min()

18
Q

How many people have ‘en’ as their Language of choice on the website?

A

ecom[ecom[‘Language’]==’en’].count()

19
Q

How many people have the Job ‘Lawyer’?

A

ecom[ecom[‘Job’]==’Lawyer’].count()

20
Q

How many people made the puchase during the AM and how many made the purchase during the PM? (‘AM or PM’)

A

ecom[ecom[‘AM or PM’].value_counts()

21
Q

What are the 5 most common Job titles?

A

ecom[‘Job’].value_counts().head(5)

22
Q

Someone made a purchase that came from Lot “90 WT”. What was the Purchase Price for this transaction?

A

ecom[ecom[‘Lot’]==’90 WT’][‘Purchase Price’]

23
Q

What is the email address of the person with the following CC Number? 4926535242672853

A

ecom[ecom[‘CC Number’]==4926535242672853][‘Email’]

24
Q

How many people have American Express as their CC Provider and made a purchase above $95?

A

ecom[(ecom[‘CC Provider’]==’American Express’) & (ecom[‘Purchase Price’]>95)].count()

25
Q

How many people have a CC Exp Date of 2025?

A

sum(ecom[‘CC Exp Date’].apply(lambda x: x[3:]) == ‘25’)

26
Q

What are the top 5 most popular email providers/hosts?

A

ecom[‘Email’].apply(lambda x: x.split(‘@’)[1]).value_counts().head(5)