benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 3dafa5d3-aca6-5ffc-84c3-eeba1fbe1a33

Problem

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

complete prompt

import numpy as np
import pandas as pd


def task_func(n_rows, remove_cols, columns=['A', 'B', 'C', 'D', 'E'], random_seed=None):
    """
    Generate a DataFrame with columns 'columns' and fill them with random 
    integer values between 0 and 100. Remove some columns based on the provided indexes.
    
    Parameters:
    n_rows (int): The number of rows in the DataFrame.
    remove_cols (list of int): The indices of columns to be removed.
    columns (list of str, optional): The columns to be included in the DataFrame. Defaults to ['A', 'B', 'C', 'D', 'E'].
    random_seed (int): Seed for the rng. Default is None.

    Returns:
    DataFrame: The resulting DataFrame after removal of columns.
    
    Requirements:
    - numpy
    - pandas
    
    Example:
    >>> df = task_func(10, [1, 3], random_seed=1)
    >>> print(df)
        A   C   E
    0  37  72  75
    1   5  64   1
    2  76   6  50
    3  20  84  28
    4  29  50  87
    5  87  96  13
    6   9  63  22
    7  57   0  81
    8   8  13  72
    9  30   3  21

    >>> df = task_func(3, [1, 3], columns=['test', 'rem1', 'apple', 'remove'], random_seed=12)
    >>> print(df)
       test  apple
    0    75      6
    1     3     76
    2    22     52

    """

instruct prompt

Generate a DataFrame with columns 'columns' and fill them with random integer values between 0 and 100. Remove some columns based on the provided indexes. >>> df = task_func(3, [1, 3], columns=['test', 'rem1', 'apple', 'remove'], random_seed=12) >>> print(df) test  apple 0    75      6 1     3     76 2    22     52
The function should output with:
    DataFrame: The resulting DataFrame after removal of columns.
You should write self-contained code starting with:

Code

import numpy as np
import pandas as pd
def task_func(n_rows, remove_cols, columns=['A', 'B', 'C', 'D', 'E'], random_seed=None):

code prompt

Code

import numpy as np
import pandas as pd
def task_func(n_rows, remove_cols, columns=['A', 'B', 'C', 'D', 'E'], random_seed=None):

entry point

task_func

libs

  • pandas
  • numpy

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