🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEpandas

pandas Documentation

📖 INDEX

No matches found.
LOADING ENGINE...

df.loc[]

AI & DATA SCIENCE // df-loc

Access a group of rows and columns by label(s) or a boolean array.

Syntax

sub_df = df.loc[1:5, ['A', 'B']]

Examples

Example 01Basic Usage
sub_df = df.loc[1:5, ['A', 'B']]

Best Practices

  • Use vectorized operations over iterations (e.g. iterrows()) for performance.
  • Always verify memory usage when loading large files.