benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf 760ae9fe-e8a3-5fb9-8414-1782e6b8b1e6
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.impute import SimpleImputer
import seaborn as sns
import matplotlib.pyplot as plt
def task_func(df):
"""
Impute missing values in the last column of the dataframe using mean imputation, then create a box plot to visualize the distribution of data in the last column.
Parameters:
df (DataFrame): The input dataframe.
Returns:
DataFrame: A pandas DataFrame with the imputed last column.
Axes: A matplotlib Axes object with the boxplot of the last column of the dataframe.
Raises:
ValueError: If the input is not a DataFrame or has no columns.
Requirements:
- numpy
- pandas
- sklearn
- seaborn
- matplotlib.pyplot
Example:
>>> df = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))
>>> df.iloc[::3, -1] = np.nan # Insert some NaN values
>>> imputed_df, ax = task_func(df)
>>> ax.get_title() # 'Boxplot of Last Column'
'Boxplot of Last Column'
>>> ax.get_xlabel() # 'D'
'D'
"""
instruct prompt
Impute missing values in the last column of the dataframe using mean imputation, then create a box plot to visualize the distribution of data in the last column.
The function should raise the exception for: ValueError: If the input is not a DataFrame or has no columns.
The function should output with:
DataFrame: A pandas DataFrame with the imputed last column.
Axes: A matplotlib Axes object with the boxplot of the last column of the dataframe.
You should write self-contained code starting with:
Code
import numpy as np
import pandas as pd
from sklearn.impute import SimpleImputer
import seaborn as sns
import matplotlib.pyplot as plt
def task_func(df):
code prompt
Code
import numpy as np
import pandas as pd
from sklearn.impute import SimpleImputer
import seaborn as sns
import matplotlib.pyplot as plt
def task_func(df):
entry point
task_func
libs
- pandas
- matplotlib
- numpy
- seaborn
- 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