benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 71d9f1a1-d347-5934-acc6-b85989663a53

Problem

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

complete prompt

import pandas as pd
import os


def task_func(data_dir: str, csv_files: list) -> pd.DataFrame:
    """
    Merge / Concatenate multiple CSV files from a specified directory into a single Pandas DataFrame.

    If an empty list of files is passed, an empty DataFrame is returned.
    
    Parameters:
    data_dir (str): The directory path where the CSV files are located.
    csv_files (list): A list of CSV file names to be merged.
    
    Returns:
    pd.DataFrame: A pandas DataFrame with the merged data.
    
    Requirements:
    - pandas
    - os
    
    Example:
    >>> df = task_func('/path/to/data/directory', ['file1.csv', 'file2.csv', 'file3.csv'])
    >>> print(df.head())
            Name  Age  Gender
    0    Simon   5     Male
    1    Bobby   32    Male
    0    Elena   13  Female
    1      Tom   23    Male
    0   Franko   12    Male
    """

instruct prompt

Merge / Concatenate multiple CSV files from a specified directory into a single Pandas DataFrame. If an empty list of files is passed, an empty DataFrame is returned.
The function should output with:
    pd.DataFrame: A pandas DataFrame with the merged data.
You should write self-contained code starting with:

Code

import pandas as pd
import os
def task_func(data_dir: str, csv_files: list) -> pd.DataFrame:

code prompt

Code

import pandas as pd
import os
def task_func(data_dir: str, csv_files: list) -> pd.DataFrame:

entry point

task_func

libs

  • pandas
  • os

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