0Pricing
Data Science Academy · درس

حسابات Series والمحاذاة

افهم كيفية محاذاة التسميات تلقائيًا أثناء العمليات.

حسابات Series والمحاذاة درس مجاني في Data Science Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Data Science Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Data Science Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Math on Whole Columns

You can do math on an entire Series at once. Operations apply to every value together, so there is no loop to write. ⚡

Add a Scalar

Adding a single number to a Series adds it to every value. This broadcast happens automatically across the whole column.

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

All the Operators Work

Subtraction, multiplication, and division behave the same way. Each one is vectorized, touching all values in a single fast pass.

print(s * 2)

Add Two Series

When you add two Series, pandas lines them up by their index labels first. This step is called alignment and it is the headline feature. 🔗

Matching Labels Combine

Where both Series share a label, their values are combined. Alignment means position does not matter, only the labels do.

a = pd.Series([1, 2], index=['x', 'y'])
b = pd.Series([10, 20], index=['x', 'y'])
print(a + b)

Order Does Not Matter

Even if the labels appear in a different order, pandas still matches them correctly. It pairs label to label, never row to row.

b = pd.Series([20, 10], index=['y', 'x'])
print(a + b)

Missing Labels Make NaN

If a label exists in only one Series, the result for it becomes NaN, meaning Not a Number. There was nothing to pair it with.

c = pd.Series([1], index=['x'])
print(a + c)

Fill the Gaps

Use the .add method with fill_value to treat missing labels as a default instead of NaN. Here zero plugs the holes.

print(a.add(c, fill_value=0))

Apply a Function

Many NumPy functions work directly on a Series and return a new one. Each value is transformed while its index stays intact.

import numpy as np
print(np.sqrt(pd.Series([4, 9, 16])))

Compare to Make Masks

Comparisons also run element-wise, giving a Series of True and False. That boolean mask is the start of filtering data.

print(s > 15)

Why Alignment Wins

Automatic alignment quietly prevents a whole class of bugs from mismatched rows. Trust the labels and let pandas pair them for you. 🛡️

Quick Check

Let's confirm how alignment handles a label gap.

Recap

You saw Series math is vectorized, that operations align by index label, and that unmatched labels yield NaN unless you fill them. Great progress! 🎉

الأسئلة الشائعة

هل درس «حسابات Series والمحاذاة» مجاني؟

نعم — نص درس «حسابات Series والمحاذاة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Data Science Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Data Science Academy 4 دروس في المجموع.

ماذا ستتعلم في «حسابات Series والمحاذاة»؟

افهم كيفية محاذاة التسميات تلقائيًا أثناء العمليات. تتمرن على Data Science Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Data Science Academy؟

لا تُشترط خبرة سابقة. Data Science Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.

كم من الوقت يستغرق درس «حسابات Series والمحاذاة»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Data Science Academy هذا؟

نعم. كل درس في Data Science Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. عمود باسم وفهرس
  2. الوصول حسب التسميات مقابل الوصول حسب المواضع
  3. حسابات Series والمحاذاة
  4. عدّ القيم واكتشافها
← العودة إلى Data Science Academy