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

แถว คอลัมน์ และดัชนี

แบบจำลองทางความคิดของ DataFrame

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

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

A Table You Can Code

A DataFrame is pandas' spreadsheet in code: rows and columns of data you can slice, sort, and compute on instantly. 📊

Two Axes, One Grid

Every DataFrame has two axes: rows run top to bottom, columns run left to right. Together they form one tidy grid of values.

Columns Are the Variables

Each column holds one variable, like price or city, and shares a single data type. Think of a column as one measured thing.

Rows Are the Records

Each row is one record: a customer, a day, a sale. Read a row across and you get the full story of one observation.

Meet the Index

The index is the label down the left side that names every row. By default it counts 0, 1, 2, but it can be anything unique.

df.index

Columns Have Labels Too

The column headers form their own label set, the columns attribute. You select data by these names instead of guessing positions.

df.columns

Shape Tells the Size

The shape attribute returns rows and columns as a pair. shape[0] is your row count, shape[1] is your column count.

df.shape  # (rows, cols)

One Column Is a Series

Pull a single column and pandas hands you a Series: a one-dimensional labeled array. A DataFrame is really a stack of Series.

df["price"]

Set a Meaningful Index

You can promote a column to be the index when it identifies rows, like an order id. It makes lookups clearer and faster.

df.set_index("order_id")

Labels Drive Everything

Pandas aligns and joins data by labels, not row order. That is why a thoughtful index quietly powers most of your analysis.

Reset When You Need To

Need a plain counting index back? reset_index moves the current index into a column and gives you fresh 0-based labels.

df.reset_index()

Quick Check

Time to test the mental model of a DataFrame.

Recap: The DataFrame Map

Rows are records, columns are variables, and the index labels every row. Know this map and the rest of pandas clicks. 🗺️

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

บทเรียน “แถว คอลัมน์ และดัชนี” ฟรีหรือไม่

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

คุณจะเรียนรู้อะไรในบทเรียน “แถว คอลัมน์ และดัชนี”

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

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

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

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

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

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

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

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

  1. แถว คอลัมน์ และดัชนี
  2. สร้าง DataFrame ตั้งแต่ต้น
  3. head, info และ describe
  4. เพิ่ม เปลี่ยนชื่อ และลบคอลัมน์
← กลับไปที่ Data Science Academy