benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 932f2954-980b-5da7-8890-c34638663b4d

Problem

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

complete prompt

from random import sample
import seaborn as sns
import pandas as pd

# Constants
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 values of multiple columns, 
    and then create n random joint plots of two columns against each other if the DataFrame is not empty.
    
    Parameters:
    df (DataFrame): The pandas DataFrame.
    tuples (list): A list of tuples, where each tuple represents a row to be removed.
    n_plots (int): The number of jointplots to be generated.
    
    Returns:
    tuple: A tuple containing:
        - DataFrame: The modified DataFrame.
        - list: A list of generated joint plots (sns.JointGrid objects) if the DataFrame is not empty, otherwise an empty list.
    
    Requirements:
    - pandas
    - seaborn
    - random
    
    Example:
    >>> import numpy as np
    >>> 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, plots = task_func(df, tuples, 3)
    '''

instruct prompt

Remove rows from a dataframe based on values of multiple columns, and then create n random joint plots of two columns against each other if the DataFrame is not empty.
The function should output with:
    tuple: A tuple containing:
    DataFrame: The modified DataFrame.
    list: A list of generated joint plots (sns.JointGrid objects) if the DataFrame is not empty, otherwise an empty list.
You should write self-contained code starting with:

Code

from random import sample
import seaborn as sns
import pandas as pd
# Constants
COLUMNS = ['A', 'B', 'C', 'D', 'E']
def task_func(df: pd.DataFrame, tuples: list, n_plots: int) -> (pd.DataFrame, list):

code prompt

Code

from random import sample
import seaborn as sns
import pandas as pd
# Constants
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
  • seaborn

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