benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 498fab8a-d90c-5ad0-b086-233977bc9367

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
import itertools

def task_func(T1, row_num=50, seed=None):
    """
    Convert elements in 'T1' to integers and create a Pandas DataFrame with random numbers. 
    The number of columns in the DataFrame is determined by the sum of the integers in 'T1', 
    and the number of rows is defined by the 'row_num' parameter.

    Parameters:
    T1 (tuple): A tuple of tuples, each containing string representations of integers.
    row_num (int, optional): Number of rows for the DataFrame. Defaults to 50.
    seed (int, optional): Seed for random number generation. Defaults to None.

    Returns:
    DataFrame: A pandas DataFrame with random numbers.

    Requirements:
    - pandas
    - numpy
    - itertools

    Example:
    >>> T1 = (('13', '17', '18', '21', '32'), ('07', '11', '13', '14', '28'), ('01', '05', '06', '08', '15', '16'))
    >>> df = task_func(T1, row_num=5, seed=2022)
    >>> print(df)
       Col_1  Col_2  Col_3  Col_4  ...  Col_222  Col_223  Col_224  Col_225
    0     92     45     49     55  ...        6       60       45       99
    1     51     17     38     83  ...       63       86       82       59
    2     27     64     73     92  ...       39       25       91       95
    3     52     40     35     22  ...       71       34       52       13
    4     54      1     79     61  ...       41       78       97       27
    <BLANKLINE>
    [5 rows x 225 columns]

    >>> df = task_func(('1', ('1', '3')), row_num=2, seed=32)
    >>> print(df)
       Col_1  Col_2  Col_3  Col_4  Col_5
    0     87     43      5     54     62
    1     88     19     71     89      3

    >>> T1 = (('1', '12'), ('1', '-12'))
    >>> df = task_func(T1, row_num=6, seed=21)
    >>> print(df)
       Col_1  Col_2
    0     73     79
    1     56      4
    2     48     35
    3     60     98
    4     74     72
    5     63     44
    """

instruct prompt

Convert elements in 'T1' to integers and create a Pandas DataFrame with random numbers. The number of columns in the DataFrame is determined by the sum of the integers in 'T1', and the number of rows is defined by the 'row_num' parameter. >>> df = task_func(('1', ('1', '3')), row_num=2, seed=32) >>> print(df) Col_1  Col_2  Col_3  Col_4  Col_5 0     87     43      5     54     62 1     88     19     71     89      3 >>> T1 = (('1', '12'), ('1', '-12')) >>> df = task_func(T1, row_num=6, seed=21) >>> print(df) Col_1  Col_2 0     73     79 1     56      4 2     48     35 3     60     98 4     74     72 5     63     44
The function should output with:
    DataFrame: A pandas DataFrame with random numbers.
You should write self-contained code starting with:

Code

import pandas as pd
import numpy as np
import itertools
def task_func(T1, row_num=50, seed=None):

code prompt

Code

import pandas as pd
import numpy as np
import itertools
def task_func(T1, row_num=50, seed=None):

entry point

task_func

libs

  • pandas
  • numpy
  • itertools

Discussion

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

Official source

initial import