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

คอลัมน์พร้อมชื่อและดัชนี

อะไรทำให้ Series แตกต่างจากรายการ

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

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

Meet the Series

A Series is pandas' one-dimensional column: a sequence of values that all share one name and one type. Think of it as a single spreadsheet column. 📊

More Than a List

A plain Python list just holds values in order. A Series pairs every value with a label, so each item has both a position and a name you can look up by.

Create One Quickly

Pass any list to pd.Series and pandas wraps it for you. This line below builds your very first Series from three numbers.

import pandas as pd
s = pd.Series([10, 20, 30])
print(s)

The Hidden Index

Notice the numbers on the left of your output. That is the index: a label for every value. Without one supplied, pandas auto-numbers from 0.

Give It Real Labels

You can set meaningful labels with the index argument. Now each value is named, which makes lookups read like plain English. 🏷️

s = pd.Series([90, 75, 88], index=['Ada', 'Bo', 'Cy'])
print(s['Bo'])

One Type Inside

Every Series carries a single dtype, like int64 or float64. Shared types are what let pandas run fast math across the whole column at once.

print(s.dtype)

Name the Whole Series

A Series can also carry its own name, separate from the index. That name becomes the column header once the Series joins a DataFrame.

s.name = 'score'
print(s.name)

Values and Index Apart

You can pull the two parts out on their own. The .values attribute gives the raw data array; .index gives the labels that tag it.

print(s.values)
print(s.index)

Build From a Dict

Hand pd.Series a dictionary and the keys become the index automatically. It is the fastest way to build a labeled column in one step.

ages = pd.Series({'Ada': 36, 'Bo': 41})
print(ages)

Length and Peek

len(s) tells you how many values sit inside, and .head() shows just the first few. Both are handy first checks on any Series.

print(len(s))
print(s.head(2))

The Column Building Block

Stack several Series side by side and you get a DataFrame. So mastering the Series means you already understand half of pandas. 🧱

Quick Check

Let's lock in what a Series carries.

Recap

You learned a Series is a named, single-typed column where every value has an index label. It is the basic block that DataFrames are built from. Nice work! 🎉

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

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

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

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

อะไรทำให้ Series แตกต่างจากรายการ คุณปฏิบัติ 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. การเข้าถึงตามป้ายกำกับเทียบกับตามตำแหน่ง
  3. คณิตศาสตร์ของ Series และการจัดแนว
  4. นับและค้นหาค่า
← กลับไปที่ Data Science Academy