benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 9bd88d26-6330-5b79-a056-f06db96dce58

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import sqlite3
import pandas as pd


def task_func(db_file: str, query: str) -> pd.DataFrame:
    """Query an SQLite database and return the results.

    This function connects to a given SQLite database, executes a given SQL query,
    and returns the results as a pandas DataFrame.

    Parameters:
    - db_file (str): Path to the SQLite database file.
    - query (str): SQL query to execute.

    Returns:
    - pd.DataFrame: A DataFrame containing the results of the executed query.

    Requirements:
    - sqlite3
    - pandas

    Example:
    >>> db_file = 'sample_database.db'
    >>> df = task_func(db_file, "SELECT * FROM users WHERE name = 'John Doe'")
    pd.DataFrame:
    id        name  age
    --  ----------  ---
    ..  John Doe   ..
    >>> df = task_func(db_file, "SELECT age, COUNT(*) AS count FROM users GROUP BY age")
    pd.DataFrame:
    age  count
    ---  -----
    25   3
    """

instruct prompt

Query an SQLite database and return the results. This function connects to a given SQLite database, executes a given SQL query, and returns the results as a pandas DataFrame.
The function should output with:
    pd.DataFrame: A DataFrame containing the results of the executed query.
You should write self-contained code starting with:

Code

import sqlite3
import pandas as pd
def task_func(db_file: str, query: str) -> pd.DataFrame:

code prompt

Code

import sqlite3
import pandas as pd
def task_func(db_file: str, query: str) -> pd.DataFrame:

entry point

task_func

libs

  • sqlite3
  • pandas

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import