Conteúdo do Curso
Advanced Techniques in pandas
Advanced Techniques in pandas
How to Delete Only NaN Values?
You've managed one way how of dealing with NaN values, but let's think about what we can do with the others. Look at the number of outliers in each column one more time:
In the previous chapter, you received the result:
PassengerId | 0 |
Survived | 0 |
Pclass | 0 |
Name | 0 |
Sex | 0 |
Age | 86 |
SibSp | 0 |
Parch | 0 |
Ticket | 0 |
Fare | 1 |
Embarked | 0 |
The simplest way is to delete all rows that contain missing values. For instance, 86
rows with ages are missing, as well as 1
row in the column 'Fare'
. Let's figure out how we can delete them. In pandas, you can do so using one simple method, similar to the one in the previous chapter, called .dropna()
:
Here, you can use inplace=True
to save all changes. Let's talk about the function. If a row in the column 'Age'
has a NaN value, this method will delete all values in the same row. The whole row will be deleted if at least one value in the row is missing.
Swipe to show code editor
Your task here is to delete all missing values and check if you did everything correctly.
- Drop the
NaN
values using theinplace=True
argument. - Calculate the number of
NaN
values.
Obrigado pelo seu feedback!
How to Delete Only NaN Values?
You've managed one way how of dealing with NaN values, but let's think about what we can do with the others. Look at the number of outliers in each column one more time:
In the previous chapter, you received the result:
PassengerId | 0 |
Survived | 0 |
Pclass | 0 |
Name | 0 |
Sex | 0 |
Age | 86 |
SibSp | 0 |
Parch | 0 |
Ticket | 0 |
Fare | 1 |
Embarked | 0 |
The simplest way is to delete all rows that contain missing values. For instance, 86
rows with ages are missing, as well as 1
row in the column 'Fare'
. Let's figure out how we can delete them. In pandas, you can do so using one simple method, similar to the one in the previous chapter, called .dropna()
:
Here, you can use inplace=True
to save all changes. Let's talk about the function. If a row in the column 'Age'
has a NaN value, this method will delete all values in the same row. The whole row will be deleted if at least one value in the row is missing.
Swipe to show code editor
Your task here is to delete all missing values and check if you did everything correctly.
- Drop the
NaN
values using theinplace=True
argument. - Calculate the number of
NaN
values.
Obrigado pelo seu feedback!
How to Delete Only NaN Values?
You've managed one way how of dealing with NaN values, but let's think about what we can do with the others. Look at the number of outliers in each column one more time:
In the previous chapter, you received the result:
PassengerId | 0 |
Survived | 0 |
Pclass | 0 |
Name | 0 |
Sex | 0 |
Age | 86 |
SibSp | 0 |
Parch | 0 |
Ticket | 0 |
Fare | 1 |
Embarked | 0 |
The simplest way is to delete all rows that contain missing values. For instance, 86
rows with ages are missing, as well as 1
row in the column 'Fare'
. Let's figure out how we can delete them. In pandas, you can do so using one simple method, similar to the one in the previous chapter, called .dropna()
:
Here, you can use inplace=True
to save all changes. Let's talk about the function. If a row in the column 'Age'
has a NaN value, this method will delete all values in the same row. The whole row will be deleted if at least one value in the row is missing.
Swipe to show code editor
Your task here is to delete all missing values and check if you did everything correctly.
- Drop the
NaN
values using theinplace=True
argument. - Calculate the number of
NaN
values.
Obrigado pelo seu feedback!
You've managed one way how of dealing with NaN values, but let's think about what we can do with the others. Look at the number of outliers in each column one more time:
In the previous chapter, you received the result:
PassengerId | 0 |
Survived | 0 |
Pclass | 0 |
Name | 0 |
Sex | 0 |
Age | 86 |
SibSp | 0 |
Parch | 0 |
Ticket | 0 |
Fare | 1 |
Embarked | 0 |
The simplest way is to delete all rows that contain missing values. For instance, 86
rows with ages are missing, as well as 1
row in the column 'Fare'
. Let's figure out how we can delete them. In pandas, you can do so using one simple method, similar to the one in the previous chapter, called .dropna()
:
Here, you can use inplace=True
to save all changes. Let's talk about the function. If a row in the column 'Age'
has a NaN value, this method will delete all values in the same row. The whole row will be deleted if at least one value in the row is missing.
Swipe to show code editor
Your task here is to delete all missing values and check if you did everything correctly.
- Drop the
NaN
values using theinplace=True
argument. - Calculate the number of
NaN
values.