Boolean Indexing
Boolean indexing lets you filter rows based on conditions. This is one of the most powerful features of Pandas.
Basic Boolean Filtering
Create a boolean mask and use it to filter:
Loading Pandas Playground...
Direct Condition in Brackets
You can put the condition directly in brackets:
Loading Pandas Playground...
Multiple Conditions
Combine conditions with & (and), | (or), ~ (not):
Loading Pandas Playground...
String Conditions
Filter based on string content:
Loading Pandas Playground...
Using isin() for Multiple Values
Check if values are in a list:
Loading Pandas Playground...
Exercise: Filter by Condition
Loading Exercise...
Exercise: Multiple Conditions
Loading Exercise...
Key Points
- Boolean indexing:
df[condition] - Combine with
&(and),|(or),~(not) - Always wrap conditions in parentheses
.str.contains()for string matching.isin([])for checking multiple values- Returns a new DataFrame (doesn't modify original)
التالي · الدرس 9 من 42
Setting & Resetting Index
قراءة 1 دقيقة
أنهيت 8 من 42 درسًا

اسأل Byte عن هذا الدرس
محادثة خاصة حول هذا الدرس. قرأ Byte الدرس كاملًا، ويجيب خلال ثوانٍ، ويُظهر القسم الذي تأتي منه كل إجابة. يمكنك السؤال بأي لغة.
الأسئلة والأجوبة
أسئلة عامة حول هذا الدرس. يجيب AI Tutor فورًا بلغتك، ويراجع فريق FreeAcademy الإجابات، ويمكن لكل المتعلمين قراءتها.

