benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 890ac286-b056-500f-baf3-d1647c818601

Problem

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

complete prompt

from random import sample
import matplotlib.pyplot as plt


# Constants
COLUMNS = ['A', 'B', 'C', 'D', 'E']


def task_func(df, tuples, n_plots):
    """
    Removes rows from a DataFrame based on values of multiple columns, 
    and then create n random line plots of two columns against each other.

    Parameters:
    - df (pd.DataFrame): The input pandas DataFrame.
    - tuples (list of tuple): A list of tuples, each tuple represents values in a row to be removed.
    - n_plots (int): The number of line plots to generate.

    Returns:
    - (pd.DataFrame, list): A tuple containing the modified DataFrame and a list of plot details.
      Each entry in the plot details list is a tuple containing the two columns plotted against each other.

    Requirements:
    - matplotlib.pyplot
    - random

    Example:
    >>> import numpy as np, pandas as pd
    >>> df = pd.DataFrame(np.random.randint(0,100,size=(100, 5)), columns=list('ABCDE'))
    >>> tuples = [(10, 20, 30, 40, 50), (60, 70, 80, 90, 100)]
    >>> modified_df, plot_details = task_func(df, tuples, 3)
    """

instruct prompt

Removes rows from a DataFrame based on values of multiple columns, and then create n random line plots of two columns against each other.
The function should output with:
    (pd.DataFrame, list): A tuple containing the modified DataFrame and a list of plot details.
    Each entry in the plot details list is a tuple containing the two columns plotted against each other.
You should write self-contained code starting with:

Code

from random import sample
import matplotlib.pyplot as plt
# Constants
COLUMNS = ['A', 'B', 'C', 'D', 'E']
def task_func(df, tuples, n_plots):

code prompt

Code

from random import sample
import matplotlib.pyplot as plt
# Constants
COLUMNS = ['A', 'B', 'C', 'D', 'E']
def task_func(df, tuples, n_plots):

entry point

task_func

libs

  • 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