analysis Flashcards

1
Q

Get summary statistics of a variable

A

df[‘var’].describe()

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

Get the sum of revenue

A

df[‘revenue’].sum()

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

Get the average

A

df[‘var’].mean()

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

Get the minimum / maximum

A

df[‘var’].min()

df[‘var’].max()

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

Get the standard deviation

A

df[‘var’].std()

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

Get the average of multiple columns

A

df[[‘var1’, ‘var2’]].mean()

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

Get both sum and mean from a variable

A

df[‘var’].agg([sum, mean])

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

Count per value of a variable

A

df[‘var’].value_counts()

add sort = True to get them immediately in count descending order

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

Count per value of a variable (but in percentage)

A

df[‘var’].value_counts(normalize = True)

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

Get the average per value of a variable

A

df.groupby(‘category’)[‘var’].mean()

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

Get the average, min, max per value of a variable

A

df.groupby(‘category’)[‘var’].agg([mean, min, max])

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

Create a pivottable output

A

df.pivot_table(values = ‘var’, index = ‘rowheader’)

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

Create a pivottable output for both mean and median

A

df.pivot_table(values = ‘var’, index = ‘rowheader’, aggfunc = [np.mean, np.median])

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

Create pivottable output on both row and column variable

A

df.pivot_table(values = ‘var’, index = ‘col’, columns = ‘col’)

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