benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 85dd1c4c-d0b9-5efd-a980-81ab1b9cf910

Problem

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

complete prompt

import pandas as pd
import sqlite3

def task_func(db_path: str, table_name: str, column_name: str) -> pd.DataFrame:
    """
    Loads data from an SQLite database into a Pandas DataFrame and performs a string replacement operation
    on a specified column. Specifically, replaces all occurrences of the newline character '\n' with the HTML line
    break tag '<br>'.
    
    Requirements:
    - pandas
    - sqlite3
    
    Parameters:
    - db_path (str): The path to the SQLite database file.
    - table_name (str): The name of the table from which to load data.
    - column_name (str): The name of the column in which to perform string replacement.
    
    Returns:
    pd.DataFrame: The modified DataFrame with replaced strings in the specified column.

    Examples:
    >>> df = task_func('./data.db', 'messages', 'content')
    >>> df.loc[0, 'content']  # Assuming the first row originally contained "Hello\nWorld"
    'Hello<br>World'
    >>> df = task_func('./another_data.db', 'comments', 'text')
    >>> df.loc[1, 'text']  # Assuming the second row originally contained "Good\nMorning"
    'Good<br>Morning'
    """

instruct prompt

Loads data from an SQLite database into a Pandas DataFrame and performs a string replacement operation on a specified column. Specifically, replaces all occurrences of the newline character '\n' with the HTML line break tag '<br>'.
The function should output with:
    pd.DataFrame: The modified DataFrame with replaced strings in the specified column.
You should write self-contained code starting with:

Code

import pandas as pd
import sqlite3
def task_func(db_path: str, table_name: str, column_name: str) -> pd.DataFrame:

code prompt

Code

import pandas as pd
import sqlite3
def task_func(db_path: str, table_name: str, column_name: 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