benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 8e9a0b97-a80d-5d0b-908d-0bc18bd1e917

Problem

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

complete prompt

import pandas as pd
import numpy as np

def task_func(data, cols):
    """
    Turn the provided data into a DataFrame and then calculate the correlation matrix of numeric columns.
    
    Parameters:
    - data (list): List of lists with the data, where the length of the inner list equals the number of columns
    - cols (list): List of column names
    
    Returns:
    - correlation_matrix (pd.DataFrame): The correlation matrix.

    Requirements:
    - pandas
    - numpy
    
    Example:
    >>> correlation_matrix = task_func([[5.1, 3.5, 1.4], [4.9, 3.0, 1.4], [4.7, 3.2, 1.3]], ['x', 'y', 'z'])
    >>> print(correlation_matrix)
              x         y         z
    x  1.000000  0.596040  0.866025
    y  0.596040  1.000000  0.114708
    z  0.866025  0.114708  1.000000
    """

instruct prompt

Turn the provided data into a DataFrame and then calculate the correlation matrix of numeric columns.
The function should output with:
    correlation_matrix (pd.DataFrame): The correlation matrix.
You should write self-contained code starting with:

Code

import pandas as pd
import numpy as np
def task_func(data, cols):

code prompt

Code

import pandas as pd
import numpy as np
def task_func(data, cols):

entry point

task_func

libs

  • pandas
  • numpy

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