benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 9c0c43bd-f254-5504-bf17-3ff62abf38d9

Problem

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

complete prompt

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

def task_func(df):
    """
    Perform exploratory data analysis on a dataframe. This function converts the 'date' column to an ordinal format,
    creates a correlation matrix, and generates a pair plot of the dataframe.

    Parameters:
        df (pandas.DataFrame): A dataframe with columns 'group', 'date', and 'value'. The 'date' column should be in datetime format.

    Returns:
        matplotlib.figure.Figure: The figure object for the correlation matrix heatmap.
        seaborn.axisgrid.PairGrid: The PairGrid object for the pair plot.

        The title of the plot is 'Correlation Matrix'. 
    Raises:
        ValueError: If the dataframe is empty, if required columns are missing, or if 'date' column is not in datetime format.

    Requirements:
        - pandas
        - matplotlib.pyplot
        - seaborn

    Example:
        >>> df = pd.DataFrame({
        ...     "group": ["A", "A", "A", "B", "B"],
        ...     "date": pd.to_datetime(["2022-01-02", "2022-01-13", "2022-02-01", "2022-02-23", "2022-03-05"]),
        ...     "value": [10, 20, 16, 31, 56],
        ... })
        >>> heatmap_fig, pairplot_grid = task_func(df)
    """

instruct prompt

Perform exploratory data analysis on a dataframe. This function converts the 'date' column to an ordinal format, creates a correlation matrix, and generates a pair plot of the dataframe. The title of the plot is 'Correlation Matrix'.
The function should raise the exception for: ValueError: If the dataframe is empty, if required columns are missing, or if 'date' column is not in datetime format.
The function should output with:
    matplotlib.figure.Figure: The figure object for the correlation matrix heatmap.
    seaborn.axisgrid.PairGrid: The PairGrid object for the pair plot.
You should write self-contained code starting with:

Code

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
def task_func(df):

code prompt

Code

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
def task_func(df):

entry point

task_func

libs

  • pandas
  • matplotlib
  • seaborn

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