Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
How to Delete Only NaN Values? | Preprocessing Data
Advanced Techniques in pandas
course content

Зміст курсу

Advanced Techniques in pandas

Advanced Techniques in pandas

1. Getting Familiar With Indexing and Selecting Data
2. Dealing With Conditions
3. Extracting Data
4. Aggregating Data
5. Preprocessing Data

bookHow 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:

PassengerId0
Survived0
Pclass0
Name0
Sex0
Age86
SibSp0
Parch0
Ticket0
Fare1
Embarked0

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.

Завдання
test

Swipe to show code editor

Your task here is to delete all missing values and check if you did everything correctly.

  1. Drop the NaN values using the inplace=True argument.
  2. Calculate the number of NaN values.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 5. Розділ 4
toggle bottom row

bookHow 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:

PassengerId0
Survived0
Pclass0
Name0
Sex0
Age86
SibSp0
Parch0
Ticket0
Fare1
Embarked0

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.

Завдання
test

Swipe to show code editor

Your task here is to delete all missing values and check if you did everything correctly.

  1. Drop the NaN values using the inplace=True argument.
  2. Calculate the number of NaN values.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 5. Розділ 4
toggle bottom row

bookHow 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:

PassengerId0
Survived0
Pclass0
Name0
Sex0
Age86
SibSp0
Parch0
Ticket0
Fare1
Embarked0

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.

Завдання
test

Swipe to show code editor

Your task here is to delete all missing values and check if you did everything correctly.

  1. Drop the NaN values using the inplace=True argument.
  2. Calculate the number of NaN values.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

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:

PassengerId0
Survived0
Pclass0
Name0
Sex0
Age86
SibSp0
Parch0
Ticket0
Fare1
Embarked0

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.

Завдання
test

Swipe to show code editor

Your task here is to delete all missing values and check if you did everything correctly.

  1. Drop the NaN values using the inplace=True argument.
  2. Calculate the number of NaN values.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 5. Розділ 4
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt