الفرز حسب عمود واحد أو عدة أعمدة
ترتيب تصاعدي وتنازلي والقيم المتساوية
الفرز حسب عمود واحد أو عدة أعمدة درس مجاني في Data Science Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Data Science Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Data Science Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Order Brings Insight
Raw rows arrive in no useful order. Sorting puts the most interesting records on top so patterns jump out at a glance. 🔎
sort_values Is Your Tool
In pandas you reorder rows with sort_values. You name the column to sort by, and pandas hands back a freshly ordered DataFrame.
df.sort_values("price")Ascending by Default
By default sort_values goes smallest to largest. So numbers climb upward and text sorts alphabetically from A to Z.
Flip to Descending
Set ascending=False when you want the biggest values first, like the top-selling products or the highest scores.
df.sort_values("sales", ascending=False)Sort by Many Columns
Pass a list of columns and pandas sorts by the first, then breaks ties using the next, and so on down the list.
df.sort_values(["region", "sales"])Mixed Sort Directions
Give ascending a list too, one flag per column. That lets you sort region A to Z while sales go high to low.
df.sort_values(["region", "sales"], ascending=[True, False])A New Frame, Not In Place
By default sort_values returns a sorted copy and leaves the original untouched, so your source data stays safe.
Sort In Place If You Mean It
Add inplace=True to rewrite the original DataFrame instead of returning a copy. Use it only when you truly want that.
Watch the Index
Sorting keeps each row label glued to its data, so the index looks shuffled afterward. That is expected, not a bug.
Reset for Clean Numbers
Want tidy 0,1,2 labels after sorting? Chain reset_index with drop=True to renumber rows from the top.
df.sort_values("sales").reset_index(drop=True)Where NaN Values Land
Missing values sink to the bottom by default. Set na_position to first if you would rather see them up top.
Quick Check
You want the highest sales on top. How do you sort?
Recap: Sorting Made Simple
You now sort with sort_values, flip with ascending, break ties using a column list, and tidy labels with reset_index. Nicely done! 🎉
الأسئلة الشائعة
هل درس «الفرز حسب عمود واحد أو عدة أعمدة» مجاني؟
نعم — نص درس «الفرز حسب عمود واحد أو عدة أعمدة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Data Science Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Data Science Academy 4 دروس في المجموع.
ماذا ستتعلم في «الفرز حسب عمود واحد أو عدة أعمدة»؟
ترتيب تصاعدي وتنازلي والقيم المتساوية تتمرن على Data Science Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Data Science Academy؟
لا تُشترط خبرة سابقة. Data Science Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «الفرز حسب عمود واحد أو عدة أعمدة»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Data Science Academy هذا؟
نعم. كل درس في Data Science Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- الفرز حسب عمود واحد أو عدة أعمدة
- ملخصك الأول باستخدام groupby
- المخططات الخطية والعمودية في matplotlib
- التسميات والعناوين ووسائل الإيضاح