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

ผลรวม ค่าเฉลี่ย และเคล็ดลับแกน

รวมค่าตามแถวหรือตามคอลัมน์

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

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

Summaries in One Call

NumPy can collapse a whole array into a single number. Methods like sum and mean turn many values into one quick summary.

a = np.array([2, 4, 6])
total = a.sum()   # 12

Mean Is the Average

The mean divides the total by the count. For the array above it returns 4.0, the everyday average you already know.

avg = a.mean()   # 4.0

The Whole Array by Default

With no extra argument, these methods reduce everything to one scalar. Every element joins the calculation, ignoring rows and columns.

m = np.arange(6).reshape(2, 3)
m.sum()   # 15

Meet the axis Argument

The real power is axis. It tells NumPy which direction to collapse, so you can summarize per row or per column instead.

axis=0 Goes Down

Set axis=0 to collapse the rows. NumPy walks down each column and returns one value per column.

m.sum(axis=0)   # [3 5 7]

axis=1 Goes Across

Set axis=1 to collapse the columns. NumPy sweeps across each row and returns one value per row.

m.sum(axis=1)   # [3 12]

A Memory Trick

Think of axis as the dimension that disappears. Collapsing axis 0 removes the row dimension, leaving a result shaped like one row.

Same Idea for mean

The axis rule is identical for mean, min, max, and more. Learn it once and it applies across every reduction NumPy offers.

m.mean(axis=0)   # [1.5 2.5 3.5]

Keep the Dimensions

Pass keepdims=True to keep the collapsed axis as size 1. This makes the result broadcast cleanly back against the original array.

m.sum(axis=1, keepdims=True)   # shape 2 x 1

Counting Along an Axis

Reductions pair with shape to answer real questions: total per category, average per day, or a count of items down each column.

Pick the Axis on Purpose

Choosing the wrong axis is a classic bug. Always ask which dimension you want to keep, then collapse the other one.

Quick Check

You have a 2D array of rows and columns.

Axis Recap

You summarized whole arrays, then steered axis to summarize per row or per column. Remember: the axis you name is the one that vanishes. 👍

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

บทเรียน “ผลรวม ค่าเฉลี่ย และเคล็ดลับแกน” ฟรีหรือไม่

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

คุณจะเรียนรู้อะไรในบทเรียน “ผลรวม ค่าเฉลี่ย และเคล็ดลับแกน”

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

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

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

บทเรียน “ผลรวม ค่าเฉลี่ย และเคล็ดลับแกน” ใช้เวลานานแค่ไหน

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

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

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

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

  1. ปรับรูปร่างและทำอาร์เรย์ให้แบน
  2. ผลรวม ค่าเฉลี่ย และเคล็ดลับแกน
  3. หน้ากากบูลีนสำหรับการเลือก
  4. ตัวเลขสุ่มและเมล็ดสุ่ม
← กลับไปที่ Data Science Academy