benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 9263cd3e-e610-58d2-9762-d762065202f0

Problem

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

complete prompt

from datetime import datetime
from random import randint
import matplotlib.pyplot as plt
import pandas as pd


TEMP_CATEGORIES = ['Cold', 'Normal', 'Hot']
FILE_PATH = 'custom_data.csv'


def task_func(hours, file_path=FILE_PATH):
    """
    Generate temperature data for the specified number of hours, save it in a CSV file, 
    and plot the data using matplotlib.
    
    Parameters:
    hours (int): The number of hours for which temperature data is to be generated.
    file_path (str, optional): Path where the CSV file will be saved. Defaults to 'temp_data.csv'.
    
    Returns:
    tuple: 
        - str: The path of the generated CSV file.
        - Axes: The plot object for further manipulation or saving.
    
    Requirements:
    - pandas
    - datetime
    - random
    - matplotlib.pyplot
    
    Data Structure:
    The function uses a dictionary to manage the generated temperature data with keys: 'Time', 'Temperature', and 'Category'.
    
    Example:
    >>> file_path, ax = task_func(24)
    >>> isinstance(file_path, str)
    True
    >>> 'custom_data.csv' in file_path
    True
    """

instruct prompt

Generate temperature data for the specified number of hours, save it in a CSV file, and plot the data using matplotlib. Data Structure: The function uses a dictionary to manage the generated temperature data with keys: 'Time', 'Temperature', and 'Category'.
The function should output with:
    tuple:
    str: The path of the generated CSV file.
    Axes: The plot object for further manipulation or saving.
You should write self-contained code starting with:

Code

from datetime import datetime
from random import randint
import matplotlib.pyplot as plt
import pandas as pd
TEMP_CATEGORIES = ['Cold', 'Normal', 'Hot']
FILE_PATH = 'custom_data.csv'
def task_func(hours, file_path=FILE_PATH):

code prompt

Code

from datetime import datetime
from random import randint
import matplotlib.pyplot as plt
import pandas as pd
TEMP_CATEGORIES = ['Cold', 'Normal', 'Hot']
FILE_PATH = 'custom_data.csv'
def task_func(hours, file_path=FILE_PATH):

entry point

task_func

libs

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