benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf d1237107-89e8-510d-bfdf-73fc5cbb5494

Problem

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

complete prompt

import seaborn as sns
import matplotlib.pyplot as plt


def task_func(df, target_values=[1, 3, 4]):
    """
    Replace all elements in DataFrame columns that do not exist in the target_values array with zeros, and then output the distribution of each column after replacing.
    - label each plot as the name of the column it corresponds to.

    Parameters:
    - df (DataFrame): The input pandas DataFrame.
    - target_values (list) : Array of values not to replace by zero.

    Returns:
    - matplotlib.axes.Axes: The Axes object of the plotted data.

    Requirements:
    - seaborn
    - matplotlib.pyplot

    Example:
    >>> import pandas as pd
    >>> import numpy as np
    >>> np.random.seed(42)
    >>> df = pd.DataFrame(np.random.randint(0,10,size=(100, 5)), columns=list('ABCDE'))
    >>> print(df.head(2))
       A  B  C  D  E
    0  6  3  7  4  6
    1  9  2  6  7  4
    >>> df1, ax = task_func(df)
    >>> print(ax)
    Axes(0.125,0.11;0.775x0.77)
    """

instruct prompt

Replace all elements in DataFrame columns that do not exist in the target_values array with zeros, and then output the distribution of each column after replacing. - label each plot as the name of the column it corresponds to.
The function should output with:
    matplotlib.axes.Axes: The Axes object of the plotted data.
You should write self-contained code starting with:

Code

import seaborn as sns
import matplotlib.pyplot as plt
def task_func(df, target_values=[1, 3, 4]):

code prompt

Code

import seaborn as sns
import matplotlib.pyplot as plt
def task_func(df, target_values=[1, 3, 4]):

entry point

task_func

libs

  • matplotlib
  • 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