Course Content

Advanced Techniques in pandas

## Advanced Techniques in pandas

1. Get Familiar With Indexing and Selecting Data

# Fill In the Missing Values

Deleting missing values is not the only way to get rid of them. You can also replace all NaNs with a defined value, for instance, with the mean value of the column or with zeros. It can be useful in a lot of cases. You will learn this in the course Learning Statistics with Python.

Look at the example of filling missing values in the column `'Age'`

with the median value of this column:

**Explanation:**

`value = data['Age'].median()`

- using the argument`value`

, we tell the`.fillna()`

function what to do with the`NaN`

values. In this case, we applied the`.fillna()`

function to the column`'Age'`

and replaced all missing values with the**median**of the column;`inplace=True`

- the argument we can use for saving changes.

Task

One of the most common ways of filling missing values is replacing them with the mean value of the column. So, your task here is to replace the `NaN`

values in the column `'Age'`

with the **mean** value of the column (using the `inplace = True`

argument). Then output the sum of the missing value in the column `'Age'`

.

Everything was clear?

# Fill In the Missing Values

Deleting missing values is not the only way to get rid of them. You can also replace all NaNs with a defined value, for instance, with the mean value of the column or with zeros. It can be useful in a lot of cases. You will learn this in the course Learning Statistics with Python.

Look at the example of filling missing values in the column `'Age'`

with the median value of this column:

**Explanation:**

`value = data['Age'].median()`

- using the argument`value`

, we tell the`.fillna()`

function what to do with the`NaN`

values. In this case, we applied the`.fillna()`

function to the column`'Age'`

and replaced all missing values with the**median**of the column;`inplace=True`

- the argument we can use for saving changes.

Task

One of the most common ways of filling missing values is replacing them with the mean value of the column. So, your task here is to replace the `NaN`

values in the column `'Age'`

with the **mean** value of the column (using the `inplace = True`

argument). Then output the sum of the missing value in the column `'Age'`

.

Everything was clear?