benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf d53d8c67-ca66-5e56-9b1a-1feb7e7cf447

Problem

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

complete prompt

import pandas as pd
import numpy as np

def task_func(df, col):
    """
    Process a Pandas DataFrame by removing a specific column and adding a 'IsEvenIndex' column.
    The 'IsEvenIndex' column is a boolean flag indicating if the index of each row is even.
    
    Parameters:
    - df (pd.DataFrame): The pandas DataFrame to process.
    - col (str): The column to remove.

    Returns:
    - df (pd.DataFrame): The processed pandas DataFrame with the specified column removed and a new 'IsEvenIndex' column added.

    Requirements:
    - pandas
    - numpy

    Example:
    >>> np.random.seed(42)
    >>> df = pd.DataFrame(np.random.randint(0,100,size=(5, 4)), columns=list('ABCD'))
    >>> df = task_func(df, 'C')
    >>> print(df)
        A   B   D  IsEvenIndex
    0  51  92  71         True
    1  60  20  86        False
    2  74  74  99         True
    3  23   2  52        False
    4   1  87  37         True
    """

instruct prompt

Process a Pandas DataFrame by removing a specific column and adding a 'IsEvenIndex' column. The 'IsEvenIndex' column is a boolean flag indicating if the index of each row is even.
The function should output with:
    df (pd.DataFrame): The processed pandas DataFrame with the specified column removed and a new 'IsEvenIndex' column added.
You should write self-contained code starting with:

Code

import pandas as pd
import numpy as np
def task_func(df, col):

code prompt

Code

import pandas as pd
import numpy as np
def task_func(df, col):

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