benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 4190e38b-eac2-506d-bfb2-2b55c7b4e8f0

Problem

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

complete prompt

import pandas as pd
from sklearn.preprocessing import StandardScaler

def task_func(df):
    """
    Standardize the 'age' and 'income' columns for each group by 'id' in a Pandas DataFrame, and return the standardized DataFrame.

    Parameters:
    df (DataFrame): A pandas DataFrame with columns ['id', 'age', 'income'].

    Returns:
    DataFrame: The pandas DataFrame after standardizing 'age' and 'income' columns.

    Raises:
    - This function will raise ValueError if the DataFrame does not have the 'id', 'age', and 'income' columns.

    Requirements:
    - pandas
    - sklearn.preprocessing.StandardScaler

    Example:
    >>> df = pd.DataFrame({ 'id': [1, 1, 2, 2, 3, 3], 'age': [25, 26, 35, 36, 28, 29], 'income': [50000, 60000, 70000, 80000, 90000, 100000]})
    >>> df_standardized = task_func(df)
    >>> print(df_standardized.iloc[0]['age'] == 25)
    False
    """

instruct prompt

Standardize the 'age' and 'income' columns for each group by 'id' in a Pandas DataFrame, and return the standardized DataFrame.
The function should raise the exception for: This function will raise ValueError if the DataFrame does not have the 'id', 'age', and 'income' columns.
The function should output with:
    DataFrame: The pandas DataFrame after standardizing 'age' and 'income' columns.
You should write self-contained code starting with:

Code

import pandas as pd
from sklearn.preprocessing import StandardScaler
def task_func(df):

code prompt

Code

import pandas as pd
from sklearn.preprocessing import StandardScaler
def task_func(df):

entry point

task_func

libs

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