benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf da568c46-01ca-553f-9c98-f0c4a5576fde

Problem

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

complete prompt

import pandas as pd
import random
import statistics
import matplotlib.pyplot as plt
import numpy as np

# Constants
RANGE = 10000  # The range within which random numbers are generated
SIZE = 1000  # The number of random numbers to generate
BIN_WIDTH = 100  # The width of bins for the histogram


def task_func():
    """
    Generates a pandas DataFrame with two columns, "Random Numbers" and "Moving Average,"
    filled with random integers and their moving average, respectively.
    Additionally, this function plots a histogram of the "Random Numbers" column.

    No Parameters.

    Returns:
        pd.DataFrame: A DataFrame with two columns:
                      - "Random Numbers": Contains a list of randomly generated integers.
                      - "Moving Average": Contains the moving average of the random integers,
                                          calculated over a window that includes the current
                                          and previous 5 integers.

    Requirements:
        - pandas
        - random
        - statistics
        - matplotlib.pyplot
        - numpy

    Example:
        >>> df = task_func()
        >>> isinstance(df, pd.DataFrame)
        True
        >>> 'Random Numbers' in df.columns and 'Moving Average' in df.columns
        True
        >>> len(df)
        1000
        >>> all(df['Random Numbers'].between(0, RANGE))
        True
    """

instruct prompt

Generates a pandas DataFrame with two columns, "Random Numbers" and "Moving Average," filled with random integers and their moving average, respectively. Additionally, this function plots a histogram of the "Random Numbers" column. No Parameters.
The function should output with:
    pd.DataFrame: A DataFrame with two columns:
    "Random Numbers": Contains a list of randomly generated integers.
    "Moving Average": Contains the moving average of the random integers,
    calculated over a window that includes the current
    and previous 5 integers.
You should write self-contained code starting with:

Code

import pandas as pd
import random
import statistics
import matplotlib.pyplot as plt
import numpy as np
# Constants
RANGE = 10000  # The range within which random numbers are generated
SIZE = 1000  # The number of random numbers to generate
BIN_WIDTH = 100  # The width of bins for the histogram
def task_func():

code prompt

Code

import pandas as pd
import random
import statistics
import matplotlib.pyplot as plt
import numpy as np
# Constants
RANGE = 10000  # The range within which random numbers are generated
SIZE = 1000  # The number of random numbers to generate
BIN_WIDTH = 100  # The width of bins for the histogram
def task_func():

entry point

task_func

libs

  • statistics
  • pandas
  • matplotlib
  • 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