Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Calculating the Number of Missing Values | Preprocessing Data
Advanced Techniques in pandas

book
Calculating the Number of Missing Values

It should be noted that it isn't convenient to check each value of the dataset for the NaN. It is more convenient to see the number of missing values to conclude columns where we have NaNs. As you remember, we have two functions to check for the missing values. To calculate the sum, just use the .sum() function. Thus, in general, we have 2 options for outputting the number of NaNs for each column:

python
data.isna().sum()
# Or
data.isnull().sum()

Okay, nothing complicated. Let's move on the task.

Tarea

Swipe to start coding

  1. Calculate the number of missing values for the dataset using one of the mentioned functions.
  2. Output the result.

Try to draw your own conclusions.

Solución

import pandas as pd

data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/4bf24830-59ba-4418-969b-aaf8117d522e/titanic_0.csv')

# Calculate the number of missing values
Nan = data.isna().sum()

# Output the result
print(Nan)

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 5. Capítulo 2
single

single

import pandas as pd

data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/4bf24830-59ba-4418-969b-aaf8117d522e/titanic_0.csv')

# Calculate the number of missing values
Nan = ___

# Output the result
___

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

some-alt