الجمع والمتوسط وحيلة المحور
اجمع البيانات عبر الصفوف أو الأعمدة.
الجمع والمتوسط وحيلة المحور درس مجاني في Data Science Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 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() # 12Mean 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.0The 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() # 15Meet 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 1Counting 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. 👍
الأسئلة الشائعة
هل درس «الجمع والمتوسط وحيلة المحور» مجاني؟
نعم — نص درس «الجمع والمتوسط وحيلة المحور» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Data Science Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Data Science Academy 4 دروس في المجموع.
ماذا ستتعلم في «الجمع والمتوسط وحيلة المحور»؟
اجمع البيانات عبر الصفوف أو الأعمدة. تتمرن على Data Science Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Data Science Academy؟
لا تُشترط خبرة سابقة. Data Science Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.
كم من الوقت يستغرق درس «الجمع والمتوسط وحيلة المحور»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Data Science Academy هذا؟
نعم. كل درس في Data Science Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- إعادة تشكيل المصفوفات وتسطيحها
- الجمع والمتوسط وحيلة المحور
- الأقنعة المنطقية للاختيار
- الأرقام العشوائية والبذور