Skip to content

Commit

Permalink
Remplacer les isnull() par isna()
Browse files Browse the repository at this point in the history
  • Loading branch information
plstonge committed Jan 27, 2025
1 parent 80ecbb0 commit 9f005f8
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/03-format.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@
"outputs": [],
"source": [
"# Pour chaque valeur, déterminer si non définie\n",
"surveys_df.isnull()"
"surveys_df.isna()"
]
},
{
Expand All @@ -517,7 +517,7 @@
"outputs": [],
"source": [
"# For each value, is the value undefined\n",
"surveys_df.isnull()"
"surveys_df.isna()"
]
},
{
Expand All @@ -530,7 +530,7 @@
"outputs": [],
"source": [
"# Sélectionner les enregistrements ayant au moins une valeur NaN\n",
"masque_nan = surveys_df.isnull().any(axis='columns')\n",
"masque_nan = surveys_df.isna().any(axis='columns')\n",
"surveys_df[masque_nan]"
]
},
Expand All @@ -544,7 +544,7 @@
"outputs": [],
"source": [
"# Select rows with at least one undefined value\n",
"nan_mask = surveys_df.isnull().any(axis='columns')\n",
"nan_mask = surveys_df.isna().any(axis='columns')\n",
"surveys_df[nan_mask]"
]
},
Expand All @@ -558,7 +558,7 @@
"outputs": [],
"source": [
"# Qu'est-ce que le code suivant va retourner?\n",
"une_selection = surveys_df[surveys_df['weight'].isnull()]\n",
"une_selection = surveys_df[surveys_df['weight'].isna()]\n",
"une_selection.groupby('species_id')['record_id'].count()"
]
},
Expand All @@ -572,7 +572,7 @@
"outputs": [],
"source": [
"# What does this do?\n",
"one_selection = surveys_df[surveys_df['weight'].isnull()]\n",
"one_selection = surveys_df[surveys_df['weight'].isna()]\n",
"one_selection.groupby('species_id')['record_id'].count()"
]
},
Expand Down Expand Up @@ -952,8 +952,7 @@
" * Méthodes : `astype()`\n",
"* **Nettoyage**\n",
" * `df.copy()`\n",
" * `isna()`, `isnull()` (le second est un alias du premier)\n",
" * `notna()`, `notnull()` (le second est un alias du premier)\n",
" * `isna()`, `notna()`\n",
" * `colonne.fillna(valeur, inplace=True)`\n",
"* **Sauvegarde**\n",
" * `df.to_csv(nom_csv, index=False)`"
Expand All @@ -975,8 +974,7 @@
" * Method: `astype()`\n",
"* **Cleaning data**\n",
" * `df.copy()`\n",
" * `isna()`, `isnull()` (the second is an alias of the first)\n",
" * `notna()`, `notnull()` (the second is an alias of the first)\n",
" * `isna()`, `notna()`\n",
" * `column.fillna(value, inplace=True)`\n",
"* **Saving a DataFrame**\n",
" * `df.to_csv(csv_filename, index=False)`"
Expand Down

0 comments on commit 9f005f8

Please sign in to comment.