BuildlyBuildly
DashboardExercisesProfileHelp
Back to all

Practice: Series & DataFrame

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
    Build a DataFrame from Lists
    Context. You collected student exam scores into two parallel lists and want them in a DataFrame for analysis. Your task. Write build_scores_df(names, scores) that returns a DataFrame with two columns, name and score, where each row pairs a name with its score (same index). Example. names=["Alice","Bob"], scores=[85,92] → | name | score | |-------|-------| | Alice | 85 | | Bob | 92 | Notes. Both inputs are always the same length. Empty inputs → empty DataFrame with both columns present.
    7 min· 10 XP
  • 2
    Shape and Column Names
    Context. Quick sanity check on a freshly loaded dataset — how big is it, and what are the columns called? Your task. Write describe_shape(df) that returns a dict with three keys: "rows" (number of rows), "columns" (number of columns), "column_names" (list of column names in their original order). Example. A 2×3 DataFrame with columns a, b, c → {"rows": 2, "columns": 3, "column_names": ["a", "b", "c"]}. Notes. Works on any DataFrame, including empty ones (0 rows but columns still defined).
    7 min· 10 XP
  • 3
    First N Rows
    Context. A preview helper — given a DataFrame and a count n, return only the first n rows. Your task. Write first_n(df, n) that returns a DataFrame containing the first n rows of df, preserving the original column order. Example. A 5-row df with n=2 → the first 2 rows as a DataFrame. Notes. If n is larger than the number of rows, return all rows. If n is 0, return an empty DataFrame (same columns, no rows).
    7 min· 10 XP