Transforming Data Flashcards

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

Function used to find missing data?

A

df.isna()

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

Function used to compile all the missing data

A

df.isna().sum()

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

Function used to drop all rows that are missing data?

A

df.dropna(inplace=True)

Using inplace=True makes the change stick

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

Function used just to drop only rows in one column?

A

df. dropna(subset=[‘Embarked’], inplace=True)

df. isna().sum()

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

Function used to drop column directly

A

df. drop(columns= ‘Cabinet, inplace=True)

df. isna().sum()

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

Function used to drop all columns that are missing any data?

A

df.dropna(axis=1, inplace=True

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

What argument can be used to decide how much incomplete data to drop in columns?

A

thresh= can be used to drop data with less than 45% of its data
df.dropna(axis=1, thresh=.45, inplace=True)

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

How to fill missing data with new category? What code is used?

A

df[‘Gender’].fillna(‘Missing, inplace=True)

Replaces Gender column with Missing

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

How to fill missing data with an average?

A

median_age = df[‘Age’].median()
df[‘Age’].fillna(median_age, inplace=True)
df.isna().sum()

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

How to fill categorical data with the most common value in the column?

A

most_common_pet = df[‘Pet Type’].mode()

df[‘Pet Type].fillna(most_common_pet, inplace=True

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