Trovare i NaN nascosti nella tabella
isna, sum e una mappa dei valori mancanti.
Trovare i NaN nascosti nella tabella è una lezione Data Science Academy gratuita su CoddyKit. Questa è la lezione 1 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Data Science Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Data Science Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
Why Missing Data Matters
Real datasets are full of gaps. Before any analysis, you need to know where missing values hide, because they quietly skew every result you trust. 🔎
Meet NaN
In pandas, an empty cell usually shows up as NaN, short for Not a Number. It is the standard marker for a value that simply is not there.
NaN Is Not Zero
A common trap: treating NaN as if it were 0. Zero is a real measurement, while NaN means you have no measurement at all. They tell very different stories.
Spotting Gaps With isna
The method isna() returns a table of True and False, one flag per cell, marking exactly where values are missing across your whole DataFrame.
missing = df.isna()
print(missing.head())Count Missing Per Column
Chain isna().sum() to count missing cells in every column at once. True counts as 1, so each total is the number of gaps in that column.
df.isna().sum()The Overall Total
Want one grand total of every gap in the table? Add another sum() to collapse the per-column counts into a single number.
df.isna().sum().sum()Missing as a Percentage
Raw counts can mislead on big tables. Divide by len(df) to see the share of each column that is missing, which guides how seriously to react.
df.isna().mean() * 100notna for the Filled Side
The opposite of isna is notna(), which flags cells that do hold a value. It is handy when you want to keep only complete rows.
df.notna().sum()A Quick Missingness Map
A heatmap of isna() turns gaps into a picture, so clusters of missing rows or columns jump out far faster than scanning numbers.
import seaborn as sns
sns.heatmap(df.isna())Rows With Any Gap
To inspect problem rows, filter where any value is missing along each row. This shows you exactly which records need attention.
df[df.isna().any(axis=1)]Why Mapping Comes First
Mapping missingness before you fix anything keeps you honest. You decide how to handle gaps based on evidence, not on a guess about how bad they are.
Quick Check
You want the number of missing values in each column. Which expression gives it?
Recap: You Can See the Gaps
You now find missing data with isna, count it per column, view it as a percentage, and map it visually. Seeing the gaps is the first step to fixing them.
Domande Frequenti
La lezione «Trovare i NaN nascosti nella tabella» è gratuita?
Sì — il testo completo di «Trovare i NaN nascosti nella tabella» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Data Science Academy, passa a CoddyKit PRO. Il corso Data Science Academy include 4 lezioni in totale.
Cosa imparerò in «Trovare i NaN nascosti nella tabella»?
isna, sum e una mappa dei valori mancanti. Eserciti Data Science Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Data Science Academy?
Non è richiesta alcuna esperienza precedente. Data Science Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 1 di 4.
Quanto tempo richiede la lezione «Trovare i NaN nascosti nella tabella»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Data Science Academy?
Sì. Ogni lezione Data Science Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Trovare i NaN nascosti nella tabella
- Eliminare o riempire: scegliere con criterio
- Imputare con media, mediana o moda
- Correggere i dtypes e le righe duplicate