benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf ece9589a-6ced-5394-a5fd-27c9d199d42d
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import pandas as pd
import json
import numpy as np
# Constants
COLUMNS = ['email', 'list']
def task_func(json_file):
"""
Load e-mail data from a JSON file, convert it into a Pandas DataFrame, calculate the sum and mean
of the list associated with each e-mail, and then record those values. Additionally, it plots the sum
and mean values for each email.
If there is no e-mail data, return an empty dataframe with the right columns (['email', 'list', 'sum', 'mean']), and None as the plot.
Parameters:
json_file (str): The path to the JSON file. The JSON file should have the structure:
[
{"email": "email1@example.com", "list": [value1, value2, ...]},
...
]
Returns:
tuple: A tuple containing:
- DataFrame: A pandas DataFrame with columns ['email', 'list', 'sum', 'mean'].
- Axes: The Axes object for the plot. None if the dataframe is empty.
Requirements:
- pandas
- json
- numpy
Example:
>>> df, ax = task_func('data/task_func/json_1.json')
>>> print(df)
"""
instruct prompt
Load e-mail data from a JSON file, convert it into a Pandas DataFrame, calculate the sum and mean of the list associated with each e-mail, and then record those values. Additionally, it plots the sum and mean values for each email. If there is no e-mail data, return an empty dataframe with the right columns (['email', 'list', 'sum', 'mean']), and None as the plot.
The function should output with:
tuple: A tuple containing:
DataFrame: A pandas DataFrame with columns ['email', 'list', 'sum', 'mean'].
Axes: The Axes object for the plot. None if the dataframe is empty.
You should write self-contained code starting with:
Code
import pandas as pd
import json
import numpy as np
# Constants
COLUMNS = ['email', 'list']
def task_func(json_file):
code prompt
Code
import pandas as pd
import json
import numpy as np
# Constants
COLUMNS = ['email', 'list']
def task_func(json_file):
entry point
task_func
libs
- pandas
- numpy
- json
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