benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 814e6b46-337a-5596-a258-9c5b908ec066

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(rows=100, columns=3):
    """
    Create a Pandas DataFrame with random alphabets in each cell.
    The DataFrame will have a specified number of rows and columns.
    Each column is named with a string from the list ['a', 'b', 'c', ...]
    depending on the number of columns specified.

    Parameters:
    - rows (int, optional): Number of rows in the DataFrame. Defaults to 100.
    - columns (int, optional): Number of columns in the DataFrame. Defaults to 3.

    Returns:
    DataFrame: A pandas DataFrame with random alphabets.

    Requirements:
    - pandas
    - numpy

    Example:
    >>> np.random.seed(0)
    >>> df = task_func(5, 3)
    >>> print(df)
       a  b  c
    0  m  p  v
    1  a  d  d
    2  h  j  t
    3  v  s  e
    4  x  g  y
    >>> df['a'].value_counts()
    a
    m    1
    a    1
    h    1
    v    1
    x    1
    Name: count, dtype: int64
    """

instruct prompt

Create a Pandas DataFrame with random alphabets in each cell. The DataFrame will have a specified number of rows and columns. Each column is named with a string from the list ['a', 'b', 'c', ...] depending on the number of columns specified.
The function should output with:
    DataFrame: A pandas DataFrame with random alphabets.
You should write self-contained code starting with:

Code

import pandas as pd
import numpy as np
def task_func(rows=100, columns=3):

code prompt

Code

import pandas as pd
import numpy as np
def task_func(rows=100, columns=3):

entry point

task_func

libs

  • pandas
  • numpy

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