benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 1b15cf6d-6a27-5ded-a922-9282313ac2e9

Problem

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

complete prompt

import pandas as pd
import seaborn as sns


def task_func(data=None):
    """
    Converts string-formatted weights to floats and plots a scatter plot of weight against height.

    This function takes a dictionary with two keys: 'Weight_String' and 'Height'. The 'Weight_String' key should 
    contain a list of weight values in string format, while the 'Height' key should have a list of corresponding 
    height values in numerical format. If the input dictionary is not provided, the function uses a default dataset.
    The function then converts the string-formatted weights into float, and plots a scatter plot to visualize 
    the relationship between weight and height.
       
    Parameters:
    - data (dict, optional): A dictionary with keys 'Weight_String' and 'Height'. 'Weight_String' is expected to be 
                           a list of weight values in string format (e.g., ['60.5', '65.7']), and 'Height' is expected 
                           to be a list of corresponding numerical height values (e.g., [160, 165]). If no dictionary 
                           is provided, a default dataset with predetermined values is used.
                           Default dictionary:
                           {
                               'Weight_String': ['60.5', '65.7', '70.2', '75.9', '80.1'],
                               'Height': [160, 165, 170, 175, 180]
                           }

    Returns:
    - ax (matplotlib.axes._axes.Axes): A scatter plot with weight on the x-axis and height on the y-axis, titled "Weight vs Height".

    Raises:
    - ValueError: If any of the values in the 'Weight_String' key are not formatted as strings. This validation ensures 
                that the weight data is in the expected format for conversion to float.

    Requirements:
    - pandas
    - seaborn

    Example:
    >>> ax = task_func()
    >>> print(ax.get_title())
    Weight vs Height
    """

instruct prompt

Converts string-formatted weights to floats and plots a scatter plot of weight against height. This function takes a dictionary with two keys: 'Weight_String' and 'Height'. The 'Weight_String' key should contain a list of weight values in string format, while the 'Height' key should have a list of corresponding height values in numerical format. If the input dictionary is not provided, the function uses a default dataset. The function then converts the string-formatted weights into float, and plots a scatter plot to visualize the relationship between weight and height.
The function should raise the exception for: ValueError: If any of the values in the 'Weight_String' key are not formatted as strings. This validation ensures that the weight data is in the expected format for conversion to float.
The function should output with:
    ax (matplotlib.axes._axes.Axes): A scatter plot with weight on the x-axis and height on the y-axis, titled "Weight vs Height".
You should write self-contained code starting with:

Code

import pandas as pd
import seaborn as sns
def task_func(data=None):

code prompt

Code

import pandas as pd
import seaborn as sns
def task_func(data=None):

entry point

task_func

libs

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