benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf d3f13a45-d6d0-51ce-a2d0-09246b817257

Problem

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

complete prompt

from itertools import combinations
from random import sample


def task_func(df, tuples, n_plots):
    """
    Removes rows from a DataFrame based on a list of tuples, each representing row values to match and remove.
    Generates up to 'n_plots' scatter plots for random combinations of two columns from the remaining DataFrame.

    Parameters:
    - df (pd.DataFrame): The input DataFrame.
    - tuples (list): A list of tuples, where each tuple contains values that, if matched, should result in the row being removed.
    - n_plots (int): The maximum number of scatter plots to generate from the remaining data.

    Returns:
    - pd.DataFrame: The DataFrame after specified rows have been removed.
    - list: A list of tuples, each containing a pair of column names used for the plot and the corresponding plot object.

    Requirements:
    - random
    - itertools

    Example:
    >>> import numpy as np, pandas as pd
    >>> df = pd.DataFrame(np.random.rand(10, 5), columns=['A', 'B', 'C', 'D', 'E'])
    >>> tuples = [(0.1, 0.2, 0.3, 0.4, 0.5)]
    >>> modified_df, plots = task_func(df, tuples, 3)
    """

instruct prompt

Removes rows from a DataFrame based on a list of tuples, each representing row values to match and remove. Generates up to 'n_plots' scatter plots for random combinations of two columns from the remaining DataFrame.
The function should output with:
    pd.DataFrame: The DataFrame after specified rows have been removed.
    list: A list of tuples, each containing a pair of column names used for the plot and the corresponding plot object.
You should write self-contained code starting with:

Code

from itertools import combinations
from random import sample
def task_func(df, tuples, n_plots):

code prompt

Code

from itertools import combinations
from random import sample
def task_func(df, tuples, n_plots):

entry point

task_func

libs

  • random
  • itertools

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