benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf c7eab383-158f-59f5-83b6-d2ba8e73a2dd
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 LabelEncoder
def task_func(df: pd.DataFrame, column_name: str) -> pd.DataFrame:
"""
Encrypt the categorical data in a specific column of a DataFrame using LabelEncoder.
Parameters:
df (pd.DataFrame): The DataFrame that contains the data.
column_name (str): The name of the column to encode.
Returns:
pd.DataFrame: The DataFrame with the encoded column.
Requirements:
- pandas
- sklearn
Example:
>>> df = pd.DataFrame({'fruit': ['apple', 'banana', 'cherry', 'apple', 'banana']})
>>> encoded_df = task_func(df, 'fruit')
>>> encoded_df['fruit'].tolist()
[0, 1, 2, 0, 1]
"""
instruct prompt
Encrypt the categorical data in a specific column of a DataFrame using LabelEncoder.
The function should output with:
pd.DataFrame: The DataFrame with the encoded column.
You should write self-contained code starting with:
Code
import pandas as pd
from sklearn.preprocessing import LabelEncoder
def task_func(df: pd.DataFrame, column_name: str) -> pd.DataFrame:
code prompt
Code
import pandas as pd
from sklearn.preprocessing import LabelEncoder
def task_func(df: pd.DataFrame, column_name: str) -> pd.DataFrame:
entry point
task_func
libs
- pandas
- sklearn
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
initial import