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

นับและค้นหาค่า

value_counts, unique และการตรวจสอบอย่างรวดเร็ว

นับและค้นหาค่า เป็นบทเรียน Data Science Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Data Science Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Get to Know Your Column

Before any analysis, you want a feel for what is inside a Series. A few quick methods summarize the contents in seconds. 🔍

A Sample Series

Here is a Series of fruit names with some repeats. We will explore its contents with handy built-in methods.

import pandas as pd
s = pd.Series(['apple', 'pear', 'apple', 'fig', 'pear', 'apple'])

Count Each Value

The value_counts method tallies how often each value appears, sorted from most to least common. It is the fastest frequency check.

print(s.value_counts())

See the Distinct Set

Call unique to get every distinct value just once, in the order first seen. It answers what kinds of values you have.

print(s.unique())

How Many Distinct

The nunique method returns the count of distinct values as a single number. Here it tells you how many fruit kinds exist.

print(s.nunique())

Shares Instead of Counts

Add normalize=True to value_counts and you get proportions instead of raw counts. Now each fruit's share sums to one.

print(s.value_counts(normalize=True))

Spot Missing Values

The isna method flags each value that is missing as True. Summing those flags counts the gaps in your column at a glance.

nums = pd.Series([1.0, None, 3.0])
print(nums.isna().sum())

Check Membership

Use isin with a list to test which values belong to a chosen set. It returns a boolean mask you can filter with later.

print(s.isin(['apple', 'fig']))

Find the Extremes

For numbers, max and min surface the largest and smallest values instantly, without sorting the whole Series yourself.

print(nums.max(), nums.min())

One-Shot Overview

The describe method bundles count, unique, top, and frequency for text, giving a tidy snapshot in a single call. 📋

print(s.describe())

Your Inspection Toolkit

Together these methods are your first inspection pass on any column. A minute spent here saves hours of confused analysis later. 🧰

Quick Check

Pick the right tool for a frequency tally.

Recap

You can now profile a Series with value_counts, unique, nunique, isna, and isin. These quick checks reveal what your data holds. Well done! 🎉

คำถามที่พบบ่อย

บทเรียน “นับและค้นหาค่า” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “นับและค้นหาค่า” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Data Science Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “นับและค้นหาค่า”

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

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

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

บทเรียน “นับและค้นหาค่า” ใช้เวลานานแค่ไหน

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

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

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

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

  1. คอลัมน์พร้อมชื่อและดัชนี
  2. การเข้าถึงตามป้ายกำกับเทียบกับตามตำแหน่ง
  3. คณิตศาสตร์ของ Series และการจัดแนว
  4. นับและค้นหาค่า
← กลับไปที่ Data Science Academy