benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf a03152c8-a0fa-5f56-8b11-55dd978d4117
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import pandas as pd
import numpy as np
def task_func(data, key, min_value, max_value):
'''
Add a new column with random values to the "data" DataFrame.
Parameters:
data (DataFrame): The input data as a pandas DataFrame.
key (str): The name of the new column to be added.
min_value (int): The minimum value for randomly generated integers in the new column.
max_value (int): The maximum value for randomly generated integers in the new column.
Returns:
DataFrame: Updated DataFrame with the new column added.
Raises:
- The function will raise an error if the input data is not pandas DataFrame
Requirements:
- numpy
- pandas
Example:
>>> np.random.seed(0)
>>> data = pd.DataFrame({'key1': ['value1', 'value2', 'value3'], 'key2': [1, 2, 3]})
>>> updated_data = task_func(data, 'new_key', 0, 10)
>>> print(updated_data)
key1 key2 new_key
0 value1 1 5
1 value2 2 0
2 value3 3 3
'''
instruct prompt
Add a new column with random values to the "data" DataFrame.
The function should raise the exception for: The function will raise an error if the input data is not pandas DataFrame
The function should output with:
DataFrame: Updated DataFrame with the new column added.
You should write self-contained code starting with:
Code
import pandas as pd
import numpy as np
def task_func(data, key, min_value, max_value):
code prompt
Code
import pandas as pd
import numpy as np
def task_func(data, key, min_value, max_value):
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