Building a DataFrame

~9 mincode completion

Write build_frame(names, scores) that returns a DataFrame with a "name" column and a "score" column, then returns its shape as a list.

The test checks the shape, so return the DataFrame and let the harness read off it.

Examples

The score column holds the values you passed in

Input
build_frame(["a", "b"], [7, 8])
Output
15

Hints

Hint 1

Work directly with the arguments names, scores and return the result rather than printing it.

Hint 2

A common slip here: built rows instead of columns.

Requirements

  • names: a list of strings

  • scores: a list of numbers, the same length

  • Return a DataFrame with columns "name" and "score".

Constraints

  • Standard library only, no imports required

  • Time limit: 200 ms, Memory: 64 MB

Where this shows up

~9 min

8 employers weight this skill

2 big tech firms, 2 frontier labs, 1 AI product company, 1 defense company, 1 enterprise vendor, 1 quant fund. Top match scores 63.

Python
import pandas as pd

def build_frame(names, scores):
    """
    Build a two-column DataFrame.

    Args:
        names: a list of strings
        scores: a list of numbers, the same length

    Returns:
        A DataFrame with columns "name" and "score".
    """
    # YOUR CODE HERE
    pass

def _score_total(names, scores):
    """Total of the score column of the frame that was built."""
    return float(build_frame(names, scores)["score"].sum())

Run your code to see results

⌘↵ runs against the visible tests

Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.