Pandas | Basics | Priority Flashcards

1
Q

How to convert text into 0/1 for machine learning.

A

df[‘Central Air’] = df[‘Central Air’].map({‘N’: 0, ‘Y’: 1})

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

Check whether any of the data frame columns contain missing values.

A

df.isnull().sum()

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

Remove rows with missing values.

A

df = df.dropna(axis=0)

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

Pandas series idioms for histogram, boxplot, kernel density plot, line plot?

Effective Pandas 14. Plotting with a Series

A

df[‘series_name’].plot.hist()/box()/kde()/line()

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

Pandas function to convert a multiindex to columns.

Effective Pandas 14. Plotting with a Series

A

unstack()

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

Pandas idiom to get percentages from a series.

Effective Pandas 14. Plotting with a Series

A

“(season2017
.resample(‘M’)
.sum()
.div(season2017.sum())
.mul(100))”

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