benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 604120ff-36df-5018-837a-8b5c578fe1a1

Problem

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

complete prompt

import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler


def task_func(data=None):
    """
    Pre-process a dataset by converting it to a Pandas DataFrame,
    replacing values less than 0.5 with zeros, and
    standardizing the data using StandardScaler.

    Parameters:
    - data (numpy.ndarray, optional): A numpy array representing the dataset. If not provided, a random dataset
      of shape (100, 5) is generated.

    Returns:
    - pandas.DataFrame: The preprocessed dataset. Original values less than 0.5 are replaced with zeros, and the
      entire dataset is standardized.

    Requirements:
    - numpy
    - pandas
    - sklearn.preprocessing.StandardScaler

    Example:
    >>> np.random.seed(0)
    >>> dataset = np.random.rand(10, 5)
    >>> preprocessed_data = task_func(dataset)
    >>> preprocessed_data.head(2)
              0         1         2        3         4
    0  0.175481  1.062315  0.244316 -0.17039 -0.647463
    1  0.461851 -0.978767  1.052947  1.06408 -0.647463
    """

instruct prompt

Pre-process a dataset by converting it to a Pandas DataFrame, replacing values less than 0.5 with zeros, and standardizing the data using StandardScaler.
The function should output with:
    pandas.DataFrame: The preprocessed dataset. Original values less than 0.5 are replaced with zeros, and the
    entire dataset is standardized.
You should write self-contained code starting with:

Code

import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
def task_func(data=None):

code prompt

Code

import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
def task_func(data=None):

entry point

task_func

libs

  • pandas
  • numpy
  • sklearn

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