BuildlyBuildly
DashboardExercisesProfileHelp
Back to all

Practice: Selection & Indexing

Drills tagged with this skill, unpassed first. Pass them all to mark the skill ready for scenarios.

Module 2: Data Analytics

0/3 done
Exercises (0/3)
  • 1
    Pick a Single Column
    Context. Extract a single column from a DataFrame for further analysis. Your task. Write get_scores(df) that returns the score column as a pandas Series (not a single-column DataFrame). Example. A df with name and score → the score Series. Notes. df["score"] returns a Series; df[["score"]] (double-bracket) would return a DataFrame — we want the first. Empty df → empty Series.
    7 min· 10 XP
  • 2
    Slice Rows by Position
    Context. Grab a positional slice of rows, regardless of the DataFrame's index. Your task. Write rows_by_position(df, start, stop) that returns rows from position start (inclusive) to stop (exclusive), using positional indexing. Example. A 5-row df with start=1, stop=3 → rows at positions 1 and 2. Notes. Same semantics as Python list slicing. start == stop → empty DataFrame. stop > len(df) → returns through end.
    7 min· 10 XP
  • 3
    Filter Rows by a Threshold
    Context. Keep only the rows whose score passes a threshold. Your task. Write rows_where_score_ge(df, threshold) that returns the rows of df where score >= threshold. Preserve original row order. Example. scores [90, 75, 85, 60], threshold=80 → rows with scores 90 and 85. Notes. Threshold higher than every score → empty DataFrame. Threshold lower than every score → all rows.
    7 min· 10 XP