benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf 92708df0-baaf-5cc3-85e9-bdaea4468db6
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import pandas as pd
import matplotlib.pyplot as plt
def task_func(df):
"""
Draw and return the daily turnover line chart from a pandas DataFrame.
Parameters:
df (DataFrame): A pandas DataFrame with 'Date' and 'Sales' columns.
Returns:
Axes: Matplotlib Axes object with the line chart.
Raises:
ValueError: If 'df' is not a DataFrame or lacks 'Date' or 'Sales' columns, or has no data to plot.
Requirements:
- pandas
- matplotlib.pyplot
Example:
>>> df = pd.DataFrame({
... 'Date': pd.date_range(start='1/1/2021', end='12/31/2021'),
... 'Sales': np.random.randint(100, 2000, size=365)
... })
>>> ax = task_func(df)
>>> ax.get_title() # Expected: 'Daily Turnover'
'Daily Turnover'
>>> ax.get_ylabel() # Expected: 'Sales'
'Sales'
"""
instruct prompt
Draw and return the daily turnover line chart from a pandas DataFrame.
The function should raise the exception for: ValueError: If 'df' is not a DataFrame or lacks 'Date' or 'Sales' columns, or has no data to plot.
The function should output with:
Axes: Matplotlib Axes object with the line chart.
You should write self-contained code starting with:
Code
import pandas as pd
import matplotlib.pyplot as plt
def task_func(df):
code prompt
Code
import pandas as pd
import matplotlib.pyplot as plt
def task_func(df):
entry point
task_func
libs
- pandas
- matplotlib
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
initial import