benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf d6ae4652-c761-5145-a1d0-fecf7d470573
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import numpy as np
import pandas as pd
def task_func(country_dict):
"""
Generates a DataFrame representing the GDP for a predefined set of countries based on their presence in the p
rovided dictionary. The GDP values are simulated with random integers to model economic data.
Parameters:
country_dict (dict): A dictionary mapping individual names to country names. The country names must correspond to
the predefined set of countries: ['USA', 'UK', 'China', 'Japan', 'Australia'].
Returns:
DataFrame: A pandas DataFrame with each country's name from the input as the index and a randomly generated GDP
value as the column. GDP values range between 1,000,000,000 and 100,000,000,000.
Requirements:
- numpy
- pandas
Example:
>>> np.random.seed(0)
>>> country_dict = {'John': 'USA', 'Alice': 'UK', 'Bob': 'China', 'Charlie': 'Japan', 'David': 'Australia'}
>>> df = task_func(country_dict)
>>> df.loc['USA']
GDP 55085855791
Name: USA, dtype: int64
"""
instruct prompt
Generates a DataFrame representing the GDP for a predefined set of countries based on their presence in the p rovided dictionary. The GDP values are simulated with random integers to model economic data.
The function should output with:
DataFrame: A pandas DataFrame with each country's name from the input as the index and a randomly generated GDP
value as the column. GDP values range between 1,000,000,000 and 100,000,000,000.
You should write self-contained code starting with:
Code
import numpy as np
import pandas as pd
def task_func(country_dict):
code prompt
Code
import numpy as np
import pandas as pd
def task_func(country_dict):
entry point
task_func
libs
- pandas
- numpy
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