العثور على NaNs المختبئة في جدولك
استخدام isna وsum وخريطة القيم المفقودة
العثور على NaNs المختبئة في جدولك درس مجاني في Data Science Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Data Science Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Data Science Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
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.
الأسئلة الشائعة
هل درس «العثور على NaNs المختبئة في جدولك» مجاني؟
نعم — نص درس «العثور على NaNs المختبئة في جدولك» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Data Science Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Data Science Academy 4 دروس في المجموع.
ماذا ستتعلم في «العثور على NaNs المختبئة في جدولك»؟
استخدام isna وsum وخريطة القيم المفقودة تتمرن على Data Science Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Data Science Academy؟
لا تُشترط خبرة سابقة. Data Science Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «العثور على NaNs المختبئة في جدولك»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Data Science Academy هذا؟
نعم. كل درس في Data Science Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- العثور على NaNs المختبئة في جدولك
- الحذف أم الملء: الاختيار بحكمة
- التعويض بالمتوسط أو الوسيط أو المنوال
- إصلاح dtypes والصفوف المكررة