Pandas Pt 1 - Cont'd (UCSD) Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

basic descriptive statistics functions for all columns on a datframe df

A

df.describe(), df.corr(), df.mean(), df.median(), df.mode(), df. min(), df.max() , df.std()

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

use axis to get statistical values for the columns or the rows (mean as example)

A

df.mean(axis = 1) ## 0 index, 1 columns

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

check if any element in a dataframe or series is `non-zero or non-empty (but mostly useful w/ a boolean column)

A

df.any()

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

check if ALL element in a dataframe or series is `non-zero or non-empty (but mostly useful w/ a boolean column)

A

df.all()

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

use describe on a column of df_var called ‘ratings’

A

df[‘ratings’].describe()

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

Create a series with Boolean values if the rating column from ratings df is > 5, then use any() to test for true on the series

A

filter_1 = ratings[‘rating’] > 5 ## not sure if this is a series, or 1 col df
filter_1.any()

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

Get the mean value from ‘rating’ col for all rows that have movieId of 1, from dataframe ratings

A

ratings[‘rating’][ratings.movieId==1].mean()

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