benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf aa060eff-ba67-5454-a1c1-7049a0cb68de
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, letters=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')):
"""
Create and return a bar chart of the frequency of letters in a DataFrame
where the column 'Letters' contains English uppercase letters.
Parameters:
df (DataFrame): The DataFrame with a 'Letters' column.
letters (list, optional): List of English uppercase letters. Defaults to A-Z.
Returns:
Axes: A Matplotlib Axes object representing the bar graph of letter frequency, with the x-axis labeled 'Letters', the y-axis labeled 'Frequency', and the title 'Letter Frequency'.
Raises:
ValueError: If 'df' is not a DataFrame or lacks the 'Letters' column.
Requirements:
- pandas
- matplotlib.pyplot
Example:
>>> import random
>>> random.seed(42)
>>> df = pd.DataFrame({'Letters': random.choices('ABCDEFGHIJKLMNOPQRSTUVWXYZ', k=100)})
>>> ax = task_func(df)
>>> plt.show()
"""
instruct prompt
Create and return a bar chart of the frequency of letters in a DataFrame where the column 'Letters' contains English uppercase letters.
The function should raise the exception for: ValueError: If 'df' is not a DataFrame or lacks the 'Letters' column.
The function should output with:
Axes: A Matplotlib Axes object representing the bar graph of letter frequency, with the x-axis labeled 'Letters', the y-axis labeled 'Frequency', and the title 'Letter Frequency'.
You should write self-contained code starting with:
Code
import pandas as pd
import matplotlib.pyplot as plt
def task_func(df, letters=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')):
code prompt
Code
import pandas as pd
import matplotlib.pyplot as plt
def task_func(df, letters=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')):
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