Selecting Rows with loc & iloc
Pandas provides two main indexers for selecting rows: loc (label-based) and iloc (position-based).
iloc: Position-Based Selection
Use iloc with integer positions (like list indexing):
Loading Pandas Playground...
loc: Label-Based Selection
Use loc with index labels:
Loading Pandas Playground...
Selecting Rows and Columns Together
Both loc and iloc can select rows AND columns:
Loading Pandas Playground...
Negative Indexing with iloc
Access from the end using negative indices:
Loading Pandas Playground...
Selecting Single Values
Use .at and .iat for scalar access:
Loading Pandas Playground...
Exercise: Row Selection
Loading Exercise...
Exercise: loc Selection
Loading Exercise...
Key Points
ilocuses integer positions (0, 1, 2, ...)locuses index labels- Both support
[rows, columns]syntax - Slicing with
locincludes the end label - Slicing with
ilocexcludes the end position - Use
.at/.iatfor fast single-value access
التالي · الدرس 8 من 42
Boolean Indexing
قراءة 1 دقيقة
أنهيت 7 من 42 درسًا

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

