0Pricing
Data Science Academy · บทเรียน

ค้นหา NaNs ที่ซ่อนอยู่ในตาราง

isna, sum และแผนที่ค่าที่หายไป

ค้นหา NaNs ที่ซ่อนอยู่ในตาราง เป็นบทเรียน Data Science Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 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() * 100

notna 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 ที่ซ่อนอยู่ในตาราง” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Data Science Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “ค้นหา NaNs ที่ซ่อนอยู่ในตาราง”

isna, sum และแผนที่ค่าที่หายไป คุณปฏิบัติ Data Science Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Data Science Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Data Science Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน

บทเรียน “ค้นหา NaNs ที่ซ่อนอยู่ในตาราง” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Data Science Academy นี้ได้ไหม

ได้ บทเรียน Data Science Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. ค้นหา NaNs ที่ซ่อนอยู่ในตาราง
  2. ลบหรือเติม: เลือกให้เหมาะสม
  3. แทนค่าด้วยค่าเฉลี่ย มัธยฐาน หรือฐานนิยม
  4. แก้ไข dtypes และแถวซ้ำ
← กลับไปที่ Data Science Academy