benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 0f09b7f6-1fff-5d04-9ab1-bc3865f24d3d

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import random
import pandas as pd
import numpy as np

def task_func(n,
          domain="samplewebsite.com",
          categories=['Sports', 'Technology', 'Health', 'Science', 'Business'],
          random_seed=None):
    """
    Generate 'n' random articles with titles, URLs, IDs, categories, and views, and return them as a DataFrame.
    Views are generated by sampling from a poisson distribution with lambda=1000.
    

    Parameters:
    n (int): The number of articles to generate.
    domain (str): The domain name for article URLs. Default is "samplewebsite.com".
    categories (list): List of categories for the articles. Default values are ['Sports', 'Technology', 'Health', 'Science', 'Business'].
    random_seeed(int): Seed for rng. Used for generating views and choosing categories.

    Returns:
    DataFrame: A pandas DataFrame with columns: 'title', 'title_url', 'id', 'category', 'views'.

    Requirements:
    - random
    - pandas
    - numpy

    Example:
    >>> df = task_func(5, random_seed=1)
    >>> print(df)
           title                    title_url  id    category  views
    0  Article 0  samplewebsite.com/Article_0   0  Technology    992
    1  Article 1  samplewebsite.com/Article_1   1    Business    962
    2  Article 2  samplewebsite.com/Article_2   2      Sports    968
    3  Article 3  samplewebsite.com/Article_3   3      Health    991
    4  Article 4  samplewebsite.com/Article_4   4      Sports    993

    >>> df = task_func(3, categories=['A', 'B'], domain='test.de', random_seed=12)
    >>> print(df)
           title          title_url  id category  views
    0  Article 0  test.de/Article_0   0        B    963
    1  Article 1  test.de/Article_1   1        B    977
    2  Article 2  test.de/Article_2   2        B   1048

    """

instruct prompt

Generate 'n' random articles with titles, URLs, IDs, categories, and views, and return them as a DataFrame. Views are generated by sampling from a poisson distribution with lambda=1000. >>> df = task_func(3, categories=['A', 'B'], domain='test.de', random_seed=12) >>> print(df) title          title_url  id category  views 0  Article 0  test.de/Article_0   0        B    963 1  Article 1  test.de/Article_1   1        B    977 2  Article 2  test.de/Article_2   2        B   1048
The function should output with:
    DataFrame: A pandas DataFrame with columns: 'title', 'title_url', 'id', 'category', 'views'.
You should write self-contained code starting with:

Code

import random
import pandas as pd
import numpy as np
def task_func(n,
          domain="samplewebsite.com",
          categories=['Sports', 'Technology', 'Health', 'Science', 'Business'],
          random_seed=None):

code prompt

Code

import random
import pandas as pd
import numpy as np
def task_func(n,
          domain="samplewebsite.com",
          categories=['Sports', 'Technology', 'Health', 'Science', 'Business'],
          random_seed=None):

entry point

task_func

libs

  • pandas
  • numpy
  • random

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