benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 3cfe558e-745c-5cd5-9825-c4f0cd2daa6b

Problem

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

complete prompt

import pandas as pd
import matplotlib.pyplot as plt
from random import sample

# Constants for column names to use in plots
COLUMNS = ['A', 'B', 'C', 'D', 'E']


def task_func(df: pd.DataFrame, tuples: list, n_plots: int) -> (pd.DataFrame, list):
    '''
    Remove rows from a dataframe based on column values and generate random scatter plots.

    Parameters:
    - df (pd.DataFrame): The input DataFrame to be modified.
    - tuples (list): A list of tuples, each representing a row's values for removal.
    - n_plots (int): Number of scatter plots to generate from random pairs of columns.

    Returns:
    - pd.DataFrame: The DataFrame after removal of specified rows.
    - list: A list containing matplotlib Axes objects of the generated plots.

    Requirements:
    - pandas
    - matplotlib.pyplot
    - random

    Example:
    >>> df = pd.DataFrame(np.random.randint(0,100,size=(100, 5)), columns=COLUMNS)
    >>> tuples = [(10, 20, 30, 40, 50), (60, 70, 80, 90, 100)]
    >>> modified_df, plots = task_func(df, tuples, 3)
    '''

instruct prompt

Remove rows from a dataframe based on column values and generate random scatter plots.
The function should output with:
    pd.DataFrame: The DataFrame after removal of specified rows.
    list: A list containing matplotlib Axes objects of the generated plots.
You should write self-contained code starting with:

Code

import pandas as pd
import matplotlib.pyplot as plt
from random import sample
# Constants for column names to use in plots
COLUMNS = ['A', 'B', 'C', 'D', 'E']
def task_func(df: pd.DataFrame, tuples: list, n_plots: int) -> (pd.DataFrame, list):

code prompt

Code

import pandas as pd
import matplotlib.pyplot as plt
from random import sample
# Constants for column names to use in plots
COLUMNS = ['A', 'B', 'C', 'D', 'E']
def task_func(df: pd.DataFrame, tuples: list, n_plots: int) -> (pd.DataFrame, list):

entry point

task_func

libs

  • pandas
  • random
  • matplotlib

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