what's this? Flashcards

1
Q

.head()

A

printing the first few rows of the DF

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

.info()

A

information about the columns

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

.mean()

A

mean of a column

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

.median()

A

median of a column

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

.min()

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

.max()

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

sort column

A

.sort_values
(‘column’)

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

get cumulative sum

A

.cumsum()

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

get cumulative maximum

A

.cummax()

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

Calculate the total Column over the whole dataset.

A

new_column = df[‘column’].sum()

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

Subset for (column) ‘type’ (“A”- content under column) stores, and calculate their total weekly (‘column’) sales.

A

new_column = df[df[‘type’] == ‘A’][‘weekly_sales’].sum()

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

Subset for (column) ‘type’ (“C”- content under column) stores, and calculate their total weekly (‘column’) sales.

A

new_column = df[df[‘type’]==’C’][‘weekly_sales’].sum()

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

Get the min of the column, ‘weekly_sales’, for each store ‘type’ using .groupby() and .agg(). store as sales_stats

A

sales_stats = sales.groupby(‘type’)[‘weekly_sales’].agg([np.min])

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

Get the min, max, and mean of the column, ‘weekly_sales’, for each store ‘type’ using .groupby() and .agg(). store as sales_stats

A

sales_stats = sales.groupby(‘type’)[‘weekly_sales’].agg([np.min, np.max, np.mean, np.median])

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

Get the mean weekly_sales (column) by type(‘column’) using .pivot_table() and store as mean_sales_by_type.

A

mean_sales_by_type = sales.pivot_table(values=’weekly_sales’, index=’type’)

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

Get the mean and median (using NumPy functions) of the column, weekly_sales, by column, type, using .pivot_table() and store as mean_med_sales.

A

mean_med_sales = sales.pivot_table(values=’weekly_sales’, index=
‘type’, aggfunc=[np.mean, np.median])

17
Q

Print the mean ‘weekly_sales’ by ‘department’ and ‘type’, using pivot_table(), and filling in any missing values with 0

A

print(sales.pivot_table
(values=’weekly_sales’, index=’department’, columns=’type’, fill_value=0))

18
Q

Get the mean of ‘weekly_sales’ by ‘type’ and ‘is_holiday’ using .pivot_table() and store as mean_sales

A

mean_sales = sales.pivot_table(values=’weekly_sales’, index=’type’, columns=’is_holiday’)