benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 8ec00ba6-1fef-5b92-8b46-ca2d4f9b3109

Problem

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

complete prompt

import os
import pandas as pd
from dateutil.parser import parse
OUTPUT_DIR = './output'

def task_func(csv_path=os.path.join(OUTPUT_DIR, 'data.csv'), date_column='date'):
    """
    Read a CSV file, convert a column of date strings into datetime objects,
    and draw a histogram of the year distribution of these dates.

    Parameters:
    - csv_path (str): The path to the CSV file. Default is the 'data.csv' in the script's directory.
    - date_column (str): The column in the CSV file with the date strings. Default is 'date'.

    Returns:
    - matplotlib.axes._axes.Axes: A histogram plot object showing the distribution of years.

    Requirements:
    - pandas
    - dateutil.parser
    - os

    Example:
    >>> import os
    >>> from unittest.mock import patch
    >>> with patch('os.path.exists', return_value=False):
    ...     task_func('nonexistent.csv')
    Traceback (most recent call last):
        ...
    FileNotFoundError: nonexistent.csv does not exist
    """

instruct prompt

Read a CSV file, convert a column of date strings into datetime objects, and draw a histogram of the year distribution of these dates.
The function should output with:
    matplotlib.axes._axes.Axes: A histogram plot object showing the distribution of years.
You should write self-contained code starting with:

Code

import os
import pandas as pd
from dateutil.parser import parse
OUTPUT_DIR = './output'
def task_func(csv_path=os.path.join(OUTPUT_DIR, 'data.csv'), date_column='date'):

code prompt

Code

import os
import pandas as pd
from dateutil.parser import parse
OUTPUT_DIR = './output'
def task_func(csv_path=os.path.join(OUTPUT_DIR, 'data.csv'), date_column='date'):

entry point

task_func

libs

  • dateutil
  • pandas
  • os

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