{"version":"sha256:b38efa530c7fa11d7515c54d35a99b2b74235c71c597193537c3220bc9aacc66","track":"code","manifest":{"track":"code","counts":{"fixed":126,"train":94,"rotating":412},"metric":"execution_pass_rate","source":"bigcode/bigcodebench at v0.1.4","digests":{"tasks":"sha256:01cd0195b50f0dc663628aa9e3da2886a01a4dd36e59dfb1bafda37067077228","tests":"sha256:56d29e02a50a083335b540077da05aae1b41edc576354c2fc19b0d07e4952d81"},"license":"Apache-2.0","excluded":{"network":90,"rare library":209,"nondeterministic":108,"test module imports the completion by module name":1},"description":"BigCodeBench function-level tasks composing calls across third-party libraries. Offline-safe subset: tasks whose tests require network access or depend on wall clock, entropy or the host environment are excluded, because the jail has no network and two validators must reach identical results.","ground_truth":"module","environment_note":"required_libraries is the exact set the sandbox must provide. Pin these rather than BigCodeBench's full 139, which shrinks both the environment and the review surface. The pinned set's digest belongs in the device profile so a validator with a different environment is refused rather than diverging silently.","binding_convention":{"how":"The completion and the test module share one namespace. The scorer concatenates the model's completion and then the test module into a single file and executes it; the module calls task_func directly, with no import of the completion by module name. This is uniform across every task in the corpus: tasks whose entry point differs, whose module never references task_func, or which import the completion from a named module are excluded at build time rather than special-cased in the scorer.","runner":"unittest","entry_point":"task_func","pass_condition":"every test in the module passes"},"required_libraries":["collections","csv","datetime","dateutil","doctest","faker","glob","itertools","json","math","matplotlib","nltk","numpy","operator","os","pandas","pathlib","pytz","random","re","scipy","seaborn","shutil","sklearn","statistics","string","tempfile","time","unittest"],"library_task_counts":{"os":115,"re":92,"csv":20,"glob":14,"json":38,"math":22,"nltk":22,"pytz":11,"time":10,"faker":25,"numpy":296,"scipy":63,"pandas":328,"random":108,"shutil":64,"string":41,"doctest":68,"pathlib":14,"seaborn":56,"sklearn":116,"datetime":46,"dateutil":6,"operator":10,"tempfile":45,"unittest":632,"itertools":47,"matplotlib":263,"statistics":7,"collections":86},"min_library_task_count":10},"counts":{"train":94,"fixed":126,"rotating":412},"tasks":[{"ref":"bigcodebench-766","gold":"\n    if not isinstance(string, str):\n        raise TypeError(\"Input string should be of type string.\")\n\n    if not isinstance(patterns, list):\n        raise TypeError(\"patterns should be a list of strings.\")\n    \n    if not all(isinstance(s, str) for s in patterns):\n        raise TypeError(\"patterns should be a list of strings.\")\n\n    \n\n    pattern_counts = collections.defaultdict(int)\n\n    for pattern in patterns:\n        pattern_counts[pattern] = len(re.findall(pattern, string))\n\n    return dict(pattern_counts)","inputs":{"source":"BigCodeBench","libraries":["collections","re","unittest"],"code_prompt":"import re\nimport collections\ndef task_func(string, patterns=['nnn', 'aaa', 'sss', 'ddd', 'fff']):\n","entry_point":"task_func"},"prompt":"Counts the occurrence of specific patterns in a string.\nThe function should raise the exception for: TypeError: If string is not a str. TypeError: If patterns is not a list of str.\nThe function should output with:\n    dict: A dictionary with patterns as keys and their counts as values.\nYou should write self-contained code starting with:\n```\nimport re\nimport collections\ndef task_func(string, patterns=['nnn', 'aaa', 'sss', 'ddd', 'fff']):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-196","gold":"    if range_limit <= 1:\n        raise ValueError(\"range_limit must be greater than 1\")\n\n    random.seed(seed)\n    np.random.seed(seed)\n\n    random_numbers = [random.randint(1, range_limit) for _ in range(length)]\n    random_numbers.sort()\n\n    # Initialize a fresh plot\n    plt.figure()\n    plot = sns.histplot(random_numbers, kde=False)\n\n    return plot.axes, random_numbers","inputs":{"source":"BigCodeBench","libraries":["doctest","matplotlib","numpy","random","seaborn","unittest"],"code_prompt":"import random\nimport seaborn as sns\nimport numpy as np\nfrom matplotlib import pyplot as plt\ndef task_func(length, range_limit=100, seed=0):\n","entry_point":"task_func"},"prompt":"Create a list of random numbers, sort them and record the distribution of the numbers in a histogram using default settings in a deterministic seaborn plot. Return the axes object and the list of random numbers.\nThe function should raise the exception for: ValueError: If range_limit is less than or equal to 1.\nThe function should output with:\n    Tuple[matplotlib.axes._axes.Axes, List[int]]: The axes object with the plot and the list of random numbers.\nYou should write self-contained code starting with:\n```\nimport random\nimport seaborn as sns\nimport numpy as np\nfrom matplotlib import pyplot as plt\ndef task_func(length, range_limit=100, seed=0):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-448","gold":"    x = np.linspace(mu - 3 * sigma, mu + 3 * sigma, 100)\n    y = norm.pdf(x, mu, sigma)\n\n    fig, ax = plt.subplots()\n    ax.plot(x, y)\n    return ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","scipy","unittest"],"code_prompt":"import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.stats import norm\ndef task_func(mu=0, sigma=1):\n","entry_point":"task_func"},"prompt":"Draw and return a subplot of a normal distribution with the given mean and standard deviation, utilizing numpy's linspace to create an array of 100 linearly spaced numbers between `mu - 3*sigma` and `mu + 3*sigma`.\nThe function should output with:\n    matplotlib.axes.Axes: The subplot representing the normal distribution.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.stats import norm\ndef task_func(mu=0, sigma=1):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-555","gold":"    correlation, _ = stats.pearsonr(a, b)\n    df = pd.DataFrame({'A': a, 'B': b})\n\n    plt.scatter(df['A'], df['B'])\n    plt.plot(np.unique(df['A']), np.poly1d(np.polyfit(df['A'], df['B'], 1))(np.unique(df['A'])), color='red')\n    plt.show()\n    return correlation, plt.gca()","inputs":{"source":"BigCodeBench","libraries":["math","matplotlib","numpy","pandas","scipy","unittest"],"code_prompt":"import matplotlib.pyplot as plt\nimport numpy as np\nimport pandas as pd\nfrom scipy import stats\ndef task_func(a, b):\n","entry_point":"task_func"},"prompt":"Calculate the Pearson correlation coefficient of two lists, generate a Pandas DataFrame from these lists, and then draw a scatter plot with a regression line.\nThe function should output with:\n    tuple: Contains two elements:\n    float: The Pearson correlation coefficient.\n    matplotlib.axes.Axes: The Axes object of the plotted scatter plot with a regression line.\nYou should write self-contained code starting with:\n```\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport pandas as pd\nfrom scipy import stats\ndef task_func(a, b):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-368","gold":"    # Setting the seed for reproducibility\n    random.seed(seed)\n    # Constants\n    files = os.listdir(src_dir)\n    if len(files) == 0:\n        raise FileNotFoundError(f\"No files found in {src_dir}\")\n\n    # Selecting a random file\n    file_name = random.choice(files)\n    \n    # Creating the source and destination paths\n    src_file = os.path.join(src_dir, file_name)\n    dest_file = os.path.join(dest_dir, file_name)\n\n    # Moving the file\n    shutil.move(src_file, dest_file)\n\n    # Returning the name of the moved file\n    return file_name","inputs":{"source":"BigCodeBench","libraries":["doctest","os","random","shutil","tempfile","unittest"],"code_prompt":"import os\nimport shutil\nimport random\ndef task_func(src_dir: str, dest_dir: str, seed:int = 100) -> str:\n","entry_point":"task_func"},"prompt":"Moves a random file from the source directory to the specified destination directory.\nThe function should output with:\n    str: The name of the file moved. Format: 'filename.extension' (e.g., 'file1.txt').\nYou should write self-contained code starting with:\n```\nimport os\nimport shutil\nimport random\ndef task_func(src_dir: str, dest_dir: str, seed:int = 100) -> str:\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-623","gold":"    # Constants\n    N_CLUSTERS = 3\n\n    data = list(chain(*L))\n    data = np.array(data).reshape(-1, 1)\n\n    kmeans = KMeans(n_clusters=N_CLUSTERS).fit(data)\n\n    fig, ax = plt.subplots()\n    ax.scatter(data, [0]*len(data), c=kmeans.labels_.astype(float))\n    \n    return ax","inputs":{"source":"BigCodeBench","libraries":["itertools","matplotlib","numpy","sklearn","unittest"],"code_prompt":"from itertools import chain\nimport numpy as np\nfrom sklearn.cluster import KMeans\ndef task_func(L):\n","entry_point":"task_func"},"prompt":"Convert a list of lists into a list of integers, apply the KMeans clustering, and return a scatter plot 'matplotlib.axes.Axes' with data points color-coded by their cluster.\nThe function should output with:\n    matplotlib.axes.Axes: An Axes object representing the scatter plot.\nYou should write self-contained code starting with:\n```\nfrom itertools import chain\nimport numpy as np\nfrom sklearn.cluster import KMeans\ndef task_func(L):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-816","gold":"\n    hand = []\n    for _ in range(5):\n        rank = random.choice(HAND_RANKS)\n        suit = random.choice(SUITS)\n        card = f'{rank}{suit}'\n        hand.append(card)\n\n    rank_counts = Counter([card[:-1] for card in hand])\n\n    return hand, rank_counts","inputs":{"source":"BigCodeBench","libraries":["collections","random","unittest"],"code_prompt":"from collections import Counter\nimport random\n# Constants\nHAND_RANKS = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']\nSUITS = ['H', 'D', 'C', 'S']\ndef task_func():\n","entry_point":"task_func"},"prompt":"Generate a random poker hand consisting of five cards, and count the frequency of each card rank. The function creates a list of five cards where each card is a string made up of a rank and a suit (e.g., \"10H\" for Ten of Hearts). It then counts the frequency of each card rank in the hand using a Counter dictionary.\nThe function should output with:\n    tuple: A tuple containing two elements:\n    hand (list): A list of five cards.\n    rank_count (counter): A Counter dictionary of card ranks with their frequencies in the hand.\nYou should write self-contained code starting with:\n```\nfrom collections import Counter\nimport random\n# Constants\nHAND_RANKS = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']\nSUITS = ['H', 'D', 'C', 'S']\ndef task_func():\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-345","gold":"    # Ensure that the df is DataFrame, not empty and the specified column exists\n    if not isinstance(df, pd.DataFrame) or df.empty or col1 not in df.columns or col2 not in df.columns:\n        raise ValueError(\"The DataFrame is empty or the specified column does not exist.\")\n    \n    ax = sns.regplot(x=col1, y=col2, data=df)\n\n    return ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","pandas","seaborn","unittest"],"code_prompt":"import pandas as pd\nimport seaborn as sns\ndef task_func(df, col1, col2):\n","entry_point":"task_func"},"prompt":"Draw a scatter plot with a regression line for two columns from a DataFrame.\nThe function should raise the exception for: Raise ValueError if the input df is not a DataFrame, empty, or does not contain the specified columns. Raise TypeError if df use non-numeric data\nThe function should output with:\n    Axes: A seaborn axes object.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport seaborn as sns\ndef task_func(df, col1, col2):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-678","gold":"\n    df = pd.DataFrame()\n    processed_path = os.path.join(path, 'processed')\n\n    if not os.path.exists(processed_path):\n        os.makedirs(processed_path)\n\n    for filename in os.listdir(path):\n        if filename.endswith('.json'):\n            file_path = os.path.join(path, filename)\n            with open(file_path, 'r') as file:\n                data = json.load(file)\n                if isinstance(data, dict):\n                    data = [data]  # Wrap scalar values in a list\n                temp_df = pd.DataFrame(data)\n                temp_df['source'] = filename\n                df = pd.concat([df, temp_df])\n\n            shutil.move(file_path, processed_path)\n\n    return df","inputs":{"source":"BigCodeBench","libraries":["json","os","pandas","shutil","unittest"],"code_prompt":"import pandas as pd\nimport json\nimport os\nimport shutil\ndef task_func(path):\n","entry_point":"task_func"},"prompt":"Processes JSON files in a directory. The function reads each JSON file alphabetically into a DataFrame and inserts a \"Source\" column that specifies the filename. The processed files are then moved to a \"processed\" subdirectory. The path may not exist initially.\nThe function should output with:\n    df (pandas.DataFrame): A DataFrame containing the data from all processed files.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport json\nimport os\nimport shutil\ndef task_func(path):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-727","gold":"    s = re.sub(r'\\W+', ' ', s)\n    vectorizer = CountVectorizer()\n    X = vectorizer.fit_transform([s] + SENTENCES)\n    return X.toarray()[0]","inputs":{"source":"BigCodeBench","libraries":["numpy","re","sklearn","unittest"],"code_prompt":"import re\nfrom sklearn.feature_extraction.text import CountVectorizer\nimport numpy as np\n# Constants\nSENTENCES = ['This is a sentence', 'Another sentence here', 'More sentences']\ndef task_func(s: str) -> np.ndarray:\n","entry_point":"task_func"},"prompt":"Vectorize a string using the Bag-of-Words model. The string is split into words and each word is treated as an attribute. The value of each attribute is the number of occurrences of the word in the string. The function also uses some predefined sentences (SENTENCES constant) for vectorization.\nThe function should output with:\n    np.ndarray: A numpy array with the vectorized string.\nYou should write self-contained code starting with:\n```\nimport re\nfrom sklearn.feature_extraction.text import CountVectorizer\nimport numpy as np\n# Constants\nSENTENCES = ['This is a sentence', 'Another sentence here', 'More sentences']\ndef task_func(s: str) -> np.ndarray:\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-520","gold":"    if not data:\n        return dict(), None\n\n    all_keys = set().union(*data)\n    for d in data:\n        for k, v in d.items():\n            if v < 0:\n                raise ValueError(\"Sales quantity must not be negative.\")\n\n    combined_dict = dict((k, [d.get(k, 0) for d in data]) for k in all_keys)\n    total_sales = {k: sum(v) for k, v in combined_dict.items()}\n    total_sales = dict(collections.OrderedDict(sorted(total_sales.items())))\n    labels, values = zip(*total_sales.items())\n\n    # Define colors dynamically to handle different numbers of fruit types\n    colors = [\"red\", \"yellow\", \"green\", \"blue\", \"purple\"] * (len(labels) // 5 + 1)\n\n    ax = plt.bar(labels, values, color=colors[: len(labels)])\n    plt.xlabel(\"Fruit\")\n    plt.ylabel(\"Total Sales\")\n    plt.title(\"Total Fruit Sales\")\n\n    return total_sales, ax","inputs":{"source":"BigCodeBench","libraries":["collections","matplotlib","unittest"],"code_prompt":"import collections\nimport matplotlib.pyplot as plt\ndef task_func(data):\n","entry_point":"task_func"},"prompt":"Combine a list of dictionaries with the same keys (fruit names) into a single dictionary, calculate the total turnover for each fruit, and return a bar chart's axes with colors representing different fruits. The colors are selected from: 'red', 'yellow', 'green', 'blue', 'purple'. The function ensures that sales quantity must not be negative, throwing a ValueError if encountered.\nThe function should output with:\n    total_sales (dict): A dictionary containing the total sales for each fruit.\n    ax (matplotlib.container.BarContainer): A bar chart of total fruit sales, or None if data is empty\nYou should write self-contained code starting with:\n```\nimport collections\nimport matplotlib.pyplot as plt\ndef task_func(data):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-663","gold":"\n    if not x or not y or not labels:\n        raise ValueError(\"Empty data lists provided.\")\n\n    def exponential_func(x, a, b, c):\n        \"\"\"Exponential function model for curve fitting.\"\"\"\n        return a * np.exp(-b * x) + c\n\n    fig, ax = plt.subplots()\n\n    for i in range(len(x)):\n        # Fit the exponential model to the data\n        popt, _ = curve_fit(exponential_func, x[i], y[i])\n\n        # Plot the fitted curve\n        ax.plot(x[i], exponential_func(x[i], *popt), label=labels[i])\n\n    ax.legend()\n\n    return fig","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","scipy","unittest"],"code_prompt":"import numpy as np\nfrom scipy.optimize import curve_fit\ndef task_func(x, y, labels):\n","entry_point":"task_func"},"prompt":"Fit an exponential curve to given data points and plot the curves with labels. It fits an exponential curve of the form: f(x) = a * exp(-b * x) + c to the provided x and y data points for each set of data and plots the fitted curves with the corresponding labels on a single matplotlib figure.\nThe function should output with:\n    matplotlib.figure.Figure: The figure object that contains the plotted curves.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nfrom scipy.optimize import curve_fit\ndef task_func(x, y, labels):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-157","gold":"\n    if not isinstance(data, np.ndarray) or data.ndim != 2:\n        raise ValueError(\"Input data must be a 2D numpy array.\")\n\n    df = pd.DataFrame(data)\n\n    # Calculate correlation matrix\n    correlation = df.corr()\n    # Plot the heatmap\n    ax = sns.heatmap(correlation, annot=True, cmap='coolwarm')\n\n    # Compute the average for each row and add it as a new column\n    df['Average'] = df.mean(axis=1)\n\n    return df, ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","pandas","seaborn","unittest"],"code_prompt":"import pandas as pd\nimport seaborn as sns\ndef task_func(data):\n","entry_point":"task_func"},"prompt":"Analyze a dataset by calculating the average of values across each row and visualizing the correlation matrix as a heatmap.\nThe function should raise the exception for: ValueError: If the input data is not a 2D array or if it contains non-numeric data.\nThe function should output with:\n    tuple: A tuple containing:\n    DataFrame: A pandas DataFrame enhanced with an 'Average' column that represents the mean across each row.\n    Axes: The matplotlib Axes object showing the heatmap of the correlations.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport seaborn as sns\ndef task_func(data):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-522","gold":"    if not data:\n        return None\n\n    combined_dict = {}\n    for d in data:\n        for k, v in d.items():\n            if v is None:\n                continue\n            elif v < 0:\n                raise ValueError(\"Scores must be non-negative.\")\n            if k in combined_dict:\n                combined_dict[k].append(v)\n            else:\n                combined_dict[k] = [v]\n\n    avg_scores = {k: sum(v) / len(v) for k, v in combined_dict.items()}\n    avg_scores = collections.OrderedDict(sorted(avg_scores.items()))\n    labels, values = zip(*avg_scores.items())\n\n    fig, ax = plt.subplots()\n    ax.bar(labels, values, color=[\"red\", \"yellow\", \"green\", \"blue\", \"purple\"])\n    ax.set_title(\"Average Student Scores\")\n    ax.set_xlabel(\"Student\")\n    ax.set_ylabel(\"Average Score\")\n\n    return ax","inputs":{"source":"BigCodeBench","libraries":["collections","matplotlib","unittest"],"code_prompt":"import collections\nimport matplotlib.pyplot as plt\ndef task_func(data):\n","entry_point":"task_func"},"prompt":"Combine a list of dictionaries with possibly differing keys (student names) into a single dictionary, calculate the average score for each student, and return a bar chart of average student scores with student on the x-axis and average score on the y-axis. This function handles data with varying dictionary lengths and missing keys by averaging available scores, ignoring None. If there is any negative score, the function raises ValueError. Bar colors can be: 'red', 'yellow', 'green', 'blue', 'purple'.\nThe function should output with:\n    ax (matplotlib.axes._axes.Axes or None): A bar chart showing the 'Average Student Scores', with\n    'Student' on the x-axis and 'Average Score' on the y-axis.\n    If data is empty, return None.\nYou should write self-contained code starting with:\n```\nimport collections\nimport matplotlib.pyplot as plt\ndef task_func(data):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-873","gold":"    if file_path is None:\n        raise ValueError(\"The file path is invalid.\")\n\n    with open(file_path, 'w', newline='') as csvfile:\n        writer = csv.writer(csvfile)\n        writer.writerow(headers)\n        for row in data:\n            if len(row) < len(headers):\n                row += (None,) * (len(headers) - len(row))\n            writer.writerow(row)\n    return os.path.abspath(file_path)","inputs":{"source":"BigCodeBench","libraries":["csv","faker","os","shutil","unittest"],"code_prompt":"import csv\nimport os\ndef task_func(data, file_path, headers):\n","entry_point":"task_func"},"prompt":"Writes a list of tuples to a CSV file. Each tuple in the 'data' list represents a row in the CSV file, with each element of the tuple corresponding to a cell in the row. If a tuple contains fewer elements than there are headers, the missing elements are filled with None. >>> task_func([('test', 123, 2), (3, -3, -15), ('hallo', 1, -2)], 'data.csv', ['test1', 'test2', 'test3']) '/user/data/data.csv' #full path depends on os and individual folder structure >>> with open('data.csv', 'r', newline='') as csvfile: >>>     reader = csv.reader(csvfile) >>>     for row in reader: >>>         print(row) ['test1', 'test2', 'test3'] ['test', '123', '2'] ['3', '-3', '-15'] ['hallo', '1', '-2'] ['1', 'hi', 'hello']\nThe function should raise the exception for: ValueError: If 'file_path' is None.\nThe function should output with:\n    str: The absolute path of the saved CSV file.\nYou should write self-contained code starting with:\n```\nimport csv\nimport os\ndef task_func(data, file_path, headers):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-862","gold":"    LETTERS = string.ascii_lowercase\n    random.seed(seed)\n    letter_dict = defaultdict(list)\n    for _ in range(n):\n        letter = random.choice(LETTERS)\n        letter_dict[letter].append(letter)\n    return letter_dict","inputs":{"source":"BigCodeBench","libraries":["collections","random","string","unittest"],"code_prompt":"import random\nimport string\nfrom collections import defaultdict\ndef task_func(n, seed=None):\n","entry_point":"task_func"},"prompt":"Generate a dictionary with lists of random lowercase english letters. Each key in the dictionary  represents a unique letter from the alphabet, and the associated value is a list, containing randomly generated instances of that letter based on a seed. The function randomly selects 'n' letters from the alphabet (a-z) and places each occurrence in the corresponding list within the dictionary. The randomness is based on the provided seed value; the same seed will produce the same distribution of letters. The dictionary has only those keys for which a letter was generated. >>> task_func(30, seed=1) defaultdict(<class 'list'>, {'e': ['e'], 's': ['s'], 'z': ['z', 'z', 'z'], 'y': ['y', 'y', 'y', 'y'], 'c': ['c'], 'i': ['i', 'i'], 'd': ['d', 'd'], 'p': ['p', 'p', 'p'], 'o': ['o', 'o'], 'u': ['u'], 'm': ['m', 'm'], 'g': ['g'], 'a': ['a', 'a'], 'n': ['n'], 't': ['t'], 'w': ['w'], 'x': ['x'], 'h': ['h']})\nThe function should output with:\n    defaultdict: A dictionary where the keys are characters ('a' to 'z') and the values\n    are lists of randomly generated letters. Each list may have 0 to 'n' occurrences of\n    its associated letter, depending on the randomness and seed.\nYou should write self-contained code starting with:\n```\nimport random\nimport string\nfrom collections import defaultdict\ndef task_func(n, seed=None):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-919","gold":"    df = pd.DataFrame(data)\n    # Define the categories\n    CATEGORIES = ['A', 'B', 'C', 'D', 'E']\n    \n    # Count occurrences of each category\n    counts = df[column].value_counts()\n    missing_categories = list(set(CATEGORIES) - set(counts.index))\n    for category in missing_categories:\n        counts[category] = 0\n\n    counts = counts.reindex(CATEGORIES)\n    \n    # Plotting\n    ax = counts.plot(kind='bar')\n    ax.set_xlabel('Category')\n    ax.set_ylabel('Count')\n    ax.set_title(f'Distribution of {column}')\n    plt.show()\n    \n    return ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","pandas","unittest"],"code_prompt":"import pandas as pd\nimport matplotlib.pyplot as plt\ndef task_func(data, column):\n","entry_point":"task_func"},"prompt":"Draw and return a bar chart that shows the distribution of categories in a specific column of a dictionary.\nNote that: The categories are defined by the constant CATEGORIES, which is a list containing ['A', 'B', 'C', 'D', 'E']. If some categories are missing in the DataFrame, they will be included in the plot with a count of zero. The x label of the plot is set to 'Category', the y label is set to 'Count', and the title is set to 'Distribution of {column}'.\nThe function should output with:\n    matplotlib.axes._axes.Axes: The Axes object for the generated plot.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport matplotlib.pyplot as plt\ndef task_func(data, column):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-405","gold":"    x = list(range(points))\n    y = [random.random() for _ in range(points)]\n\n    _, ax = plt.subplots()\n    ax.plot(x, y)\n\n    return y, ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","random","unittest"],"code_prompt":"import random\nimport matplotlib.pyplot as plt\ndef task_func(points: int):\n","entry_point":"task_func"},"prompt":"Generate a plot of random numbers such that indices are on the x-axis and generated numbers are on the y-axis.\nThe function should output with:\n    Returns a tuple containing:\n    A list of generated random numbers.\n    A matplotlib Axes object representing the plot.\nYou should write self-contained code starting with:\n```\nimport random\nimport matplotlib.pyplot as plt\ndef task_func(points: int):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-668","gold":"    min_length = math.inf\n    min_subseq = []\n\n    for r in range(1, len(x) + 1):\n        for subseq in itertools.combinations(x.items(), r):\n            length = sum(length for letter, length in subseq)\n            if length < min_length:\n                min_length = length\n                min_subseq = [letter for letter, length in subseq]\n\n    return min_subseq","inputs":{"source":"BigCodeBench","libraries":["itertools","math","unittest"],"code_prompt":"import itertools\nimport math\ndef task_func(x):\n","entry_point":"task_func"},"prompt":"Find the sub-sequence of a dictionary, x, with the minimum total length, where the keys are letters and the values are their lengths.\nThe function should output with:\n    list: The subsequence with the minimum total length.\nYou should write self-contained code starting with:\n```\nimport itertools\nimport math\ndef task_func(x):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-673","gold":"    if not os.path.exists(directory):\n        os.makedirs(directory)\n\n    for i in range(n_files):\n        filename = os.path.join(directory, f\"file_{i+1}.txt\")\n\n        with open(filename, 'w') as file:\n            file.write(str(random.randint(0, 9)))\n            file.seek(0)\n\n    return n_files","inputs":{"source":"BigCodeBench","libraries":["os","random","shutil","unittest"],"code_prompt":"import os\nimport random\ndef task_func(directory, n_files):\n","entry_point":"task_func"},"prompt":"Create n random txt files in a specific directory, write only a single digit random integer into each file, and then reset the cursor to the beginning of each file. The file names start from 'file_1.txt' and increment by 1 for each file.\nThe function should output with:\n    n_files (int): The number of files generated.\nYou should write self-contained code starting with:\n```\nimport os\nimport random\ndef task_func(directory, n_files):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-229","gold":"    if seed is not None:\n        random.seed(seed)\n    \n    log_entries = []\n    current_time = datetime.now()\n    for _ in range(num_entries):\n        user = random.choice(USERS)\n        action = random.choice(['login', 'logout', 'view_page', 'edit_profile', 'post_message'])\n        timestamp = current_time.strftime('%Y-%m-%dT%H:%M:%S')\n        log_entries.append({'user': user, 'action': action, 'timestamp': timestamp})\n        current_time -= timedelta(minutes=random.randint(1, 60))\n\n    with open(file_path, 'w') as json_file:\n        json.dump(log_entries, json_file, indent=4)\n\n    return file_path","inputs":{"source":"BigCodeBench","libraries":["datetime","doctest","json","os","random","tempfile","unittest"],"code_prompt":"import json\nimport random\nfrom datetime import datetime, timedelta\n# Constants\nUSERS = ['Alice', 'Bob', 'Charlie', 'Dave', 'Eve']\ndef task_func(file_path, num_entries, seed=None):\n","entry_point":"task_func"},"prompt":"Create a JSON file on a specific file path with random user activity data. The number of entries in the JSON file is determined by num_entries. The written JSON file contains a list of dictionaries, with each dictionary representing a log entry with the following keys: 'user', 'action', and 'timestamp'.\nThe function should output with:\n    str: The file path of the generated JSON file.\nYou should write self-contained code starting with:\n```\nimport json\nimport random\nfrom datetime import datetime, timedelta\n# Constants\nUSERS = ['Alice', 'Bob', 'Charlie', 'Dave', 'Eve']\ndef task_func(file_path, num_entries, seed=None):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-949","gold":"    if seed is not None:\n        np.random.seed(seed)\n    matrix = np.random.rand(rows, columns)\n    df = pd.DataFrame(matrix)\n    \n    return df","inputs":{"source":"BigCodeBench","libraries":["numpy","pandas","unittest"],"code_prompt":"import numpy as np\nimport pandas as pd\ndef task_func(rows, columns, seed=None):\n","entry_point":"task_func"},"prompt":"Generate a DataFrame with random values within a specified range. This function creates a matrix of given dimensions filled with random values between 0 and 1 and returns it as a Pandas DataFrame. Users have the option to set a random seed for reproducible results.\nThe function should output with:\n    DataFrame: A Pandas DataFrame containing the generated random values.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport pandas as pd\ndef task_func(rows, columns, seed=None):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-75","gold":"    if not isinstance(df, pd.DataFrame):\n        raise TypeError(\"Input must be a pandas DataFrame\")\n    if not df.empty:\n        raise ValueError(\"Input DataFrame must be empty\")\n    if sales_lower_bound >= sales_upper_bound:\n        raise ValueError(\"sales_lower_bound must be less than sales_upper_bound\")\n\n    if fruits is None:\n        fruits = ['Apple', 'Banana', 'Cherry', 'Date', 'Elderberry']\n    if days is None:\n        # Set days to range from January 1, 2024, to January 7, 2024\n        days = [datetime(2024, 1, 1) + timedelta(days=x) for x in range(7)]\n\n    if seed is not None:\n        np.random.seed(seed)\n\n    data = list(itertools.product(fruits, days))\n    sales_data = pd.DataFrame(data, columns=['Fruit', 'Day'])\n    sales_data['Sales'] = np.random.randint(sales_lower_bound, sales_upper_bound, size=len(data))\n\n    result_df = pd.concat([df, sales_data])\n    plot = sns.boxplot(x='Fruit', y='Sales', data=result_df)\n\n    return result_df, plot","inputs":{"source":"BigCodeBench","libraries":["datetime","itertools","numpy","pandas","seaborn","unittest"],"code_prompt":"import pandas as pd\nimport numpy as np\nimport itertools\nfrom datetime import datetime, timedelta\nimport seaborn as sns\ndef task_func(df, fruits=None, days=None, seed=None, sales_lower_bound=1, sales_upper_bound=50):\n","entry_point":"task_func"},"prompt":"Appends randomly generated sales data for specified fruits over a given range of days to a DataFrame, and returns a seaborn boxplot of the sales.\nThe function should raise the exception for: TypeError: If 'df' is not a pandas DataFrame. ValueError: If 'df' is not empty or  If 'sales_lower_bound' is not less than 'sales_upper_bound'.\nThe function should output with:\n    Tuple[pd.DataFrame, sns.axisgrid.FacetGrid]: Updated DataFrame with sales data and a seaborn boxplot of the sales.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport numpy as np\nimport itertools\nfrom datetime import datetime, timedelta\nimport seaborn as sns\ndef task_func(df, fruits=None, days=None, seed=None, sales_lower_bound=1, sales_upper_bound=50):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-470","gold":"    _, ax = plt.subplots()\n    ax.hist(\n        myList, bins=np.arange(min(myList), max(myList) + 2) - 0.5, edgecolor=\"black\"\n    )\n    ax.set_xlabel(\"Value\")\n    ax.set_ylabel(\"Frequency\")\n    ax.set_title(\"Histogram of Values\")\n    return ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","unittest"],"code_prompt":"import matplotlib.pyplot as plt\nimport numpy as np\ndef task_func(myList):\n","entry_point":"task_func"},"prompt":"Draws a histogram of the values in a list and returns the plot's Axes. For visualization: - Bin edges are adjusted to align with integer values in `myList`. - Histogram bars are outlined in black. - X-axis label: 'Value' - Y-axis label: 'Frequency' - Plot title: 'Histogram of Values'\nThe function should output with:\n    ax (matplotlib.axes._axes.Axes): Axes object of the histogram plot.\nYou should write self-contained code starting with:\n```\nimport matplotlib.pyplot as plt\nimport numpy as np\ndef task_func(myList):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-660","gold":"    scaler = StandardScaler()\n\n    fig, ax = plt.subplots()\n\n    # Iterate over the datasets, scale each, and plot\n    for i in range(len(x)):\n        # Combine x and y values and scale them\n        xy = np.vstack((x[i], y[i])).T  # Transpose to get correct shape for scaling\n        xy_scaled = scaler.fit_transform(xy)  # Scale data\n\n        # Plot scaled data\n        ax.plot(xy_scaled[:, 0], xy_scaled[:, 1], label=labels[i])\n\n    ax.legend()  # Add a legend to the plot\n\n    return fig  # Return the figure object containing the plot","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","sklearn","unittest"],"code_prompt":"import matplotlib.pyplot as plt\nimport numpy as np\nfrom sklearn.preprocessing import StandardScaler\ndef task_func(x, y, labels):\n","entry_point":"task_func"},"prompt":"Scale the \"x\" and \"y\" arrays using the standard scaler of sklearn and plot them with given labels. Each pair of x and y arrays are scaled independently and plotted as a separate series with a label.\nThe function should output with:\n    matplotlib.figure.Figure: The figure object containing the plot.\nYou should write self-contained code starting with:\n```\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom sklearn.preprocessing import StandardScaler\ndef task_func(x, y, labels):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-974","gold":"    source_path = pathlib.Path(source_path).resolve()\n    destination_path = pathlib.Path(destination_path).resolve()\n\n    if not (source_path.exists() and source_path.is_dir()):\n        raise ValueError(\"source_path must be an existing directory.\")\n\n    destination_path.mkdir(parents=True, exist_ok=True)\n\n    results = []\n    for entry in source_path.iterdir():\n        if entry.is_file():\n            results.append(str(entry.name))\n            shutil.copy(str(entry), str(destination_path))\n    return (source_path.name, results)","inputs":{"source":"BigCodeBench","libraries":["pathlib","shutil","tempfile","unittest"],"code_prompt":"import shutil\nimport pathlib\ndef task_func(source_path, destination_path):\n","entry_point":"task_func"},"prompt":"Lists files in the specified source directory without descending into subdirectories and copies them to a destination directory.\nThe function should raise the exception for: ValueError: If source_path does not exist or is not a directory.\nThe function should output with:\n    Tuple[str, List[str]]: A tuple containing the name of the source directory and a list of filenames (not\n    full paths) that were copied.\nYou should write self-contained code starting with:\n```\nimport shutil\nimport pathlib\ndef task_func(source_path, destination_path):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-427","gold":"    df = pd.merge(df1, df2, on=\"id\")\n    X = df[features]\n    y = df[target]\n    model = LinearRegression()\n    model.fit(X, y)\n    y_pred = model.predict(X)\n    residuals = y - y_pred\n    fig, ax = plt.subplots()\n    ax.scatter(y_pred, residuals)  # scatter plot of residuals\n    ax.axhline(y=0, color=\"r\", linestyle=\"-\")  # horizontal line at y=0\n    ax.set_xlabel(\"Predicted Values\")\n    ax.set_ylabel(\"Residuals\")\n    ax.set_title(\"Residuals Plot\")\n    return {\n        \"coefficients\": list(model.coef_),\n        \"intercept\": model.intercept_,\n        \"residuals_plot\": ax,\n    }","inputs":{"source":"BigCodeBench","libraries":["matplotlib","pandas","sklearn","unittest"],"code_prompt":"import pandas as pd\nfrom sklearn.linear_model import LinearRegression\nimport matplotlib.pyplot as plt\ndef task_func(df1, df2, features=[\"feature1\", \"feature2\", \"feature3\"], target=\"target\"):\n","entry_point":"task_func"},"prompt":"Perform linear regression analysis with specified characteristics and targets. The function should merge two dataframes based on the 'id' column, perform linear regression using columns specified in features to predict the target, and plot the residuals.\nThe function should output with:\n    dict: A dictionary containing:\n    'coefficients': Regression coefficients (list).\n    'intercept': Regression intercept (float).\n    'residuals_plot': A matplotlib Axes object representing the residuals plot, with the title 'Residuals Plot', x-axis label 'Predicted Values', and y-axis label 'Residuals'.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nfrom sklearn.linear_model import LinearRegression\nimport matplotlib.pyplot as plt\ndef task_func(df1, df2, features=[\"feature1\", \"feature2\", \"feature3\"], target=\"target\"):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-387","gold":"    if max_range < 1:\n        raise ValueError(\"max_range must be a positive integer\")\n\n    np.random.seed(seed)\n    city_population = {\n        city: (np.random.randint(1, max_range) if city in CITIES else -1) \n        for _, city in city_dict.items() if isinstance(city, str)\n    }\n\n    # Plotting the bar chart\n    plt.figure()\n    ax = plt.bar(city_population.keys(), city_population.values())\n    plt.xlabel('City')\n    plt.ylabel('Population')\n    plt.title('City Populations')\n\n    return city_population, plt.gca()","inputs":{"source":"BigCodeBench","libraries":["doctest","matplotlib","numpy","unittest"],"code_prompt":"import numpy as np\nimport matplotlib.pyplot as plt\n# Constants\nCITIES = ['New York', 'London', 'Beijing', 'Tokyo', 'Sydney', 'Paris', 'Berlin', 'Moscow', 'Madrid', 'Rome']\ndef task_func(city_dict, max_range=1000000, seed=0):\n","entry_point":"task_func"},"prompt":"Given a constant list of cities (CITIES) and a dictionary 'city_dict' of people's names and their favorite cities, this function generates a dictionary of city populations for the cities in the list and plots the population data using a bar chart. The population values are randomly generated integers between 1 and 'max_range' if the city is in the list of cities, otherwise the population value is -1. The random number generator is seeded with the value 'seed' before generating the population values.\nThe function should output with:\n    dict: A dictionary with city names as keys and randomly generated populations as values.\n    matplotlib.axes.Axes: The Axes object of the plot for further manipulation or testing.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport matplotlib.pyplot as plt\n# Constants\nCITIES = ['New York', 'London', 'Beijing', 'Tokyo', 'Sydney', 'Paris', 'Berlin', 'Moscow', 'Madrid', 'Rome']\ndef task_func(city_dict, max_range=1000000, seed=0):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-910","gold":"    if len(letters) != len(repetitions) or len(letters) != len(colors) or len(letters) == 0:\n        raise ValueError(\"All lists must be the same length and non-empty.\")\n        \n    # Count the frequency of each letter based on repetitions\n    counts = np.array(repetitions)\n    \n    # Create the bar chart\n    fig, ax = plt.subplots()\n    ax.bar(letters, counts, color=colors)\n    ax.set_xlabel('Letters')\n    ax.set_ylabel('Frequency')\n    ax.set_title('Frequency of Letters')\n    \n    return ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","unittest"],"code_prompt":"import numpy as np\nimport matplotlib.pyplot as plt\ndef task_func(letters, repetitions, colors):\n","entry_point":"task_func"},"prompt":"Create a bar chart to visualize the frequency of each letter in a flattened list formed by multiple repetitions of the original list. Each repetition of the list is associated with a different color in the chart.\nNote that: Generate a bar chart for the frequency of letters, where each letter's frequency is determined by its number of repetitions. Each letter's bar in the chart is colored according to the specified color. The length of the list `colors` should match the number of repetitions of `letters`. The lists 'letters' and 'colors' cannot be empty.\nThe function should raise the exception for: ValueError: If the lengths of the input lists do not match or if any list is empty.\nThe function should output with:\n    Returns the Matplotlib Axes object representing the created bar chart, with the x-axis labeled 'Letters', y-axis labeled 'Frequency', and title 'Frequency of Letters'.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport matplotlib.pyplot as plt\ndef task_func(letters, repetitions, colors):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-959","gold":"\n    def replace_with_random_char(c):\n        if c.isalpha():\n            if c.islower():\n                return random.choice(string.ascii_lowercase)\n            else:\n                return random.choice(string.ascii_uppercase)\n        return c\n\n    if seed is not None:\n        random.seed(seed)\n    return \"\".join(replace_with_random_char(c) for c in text)","inputs":{"source":"BigCodeBench","libraries":["random","string","unittest"],"code_prompt":"import string\nimport random\ndef task_func(text, seed=None):\n","entry_point":"task_func"},"prompt":"Transforms the input text by replacing each alphabetic character with a random letter, while preserving the case and non-alphabetic characters of the original text.\nNote that: Notes: Alphabet replacements are chosen from ascii characters of the same case as the original.\nThe function should output with:\n    str: A transformed string with random letters replacing the alphabetic characters of the input text,\n    preserving non-alphabetic characters and the original case.\nYou should write self-contained code starting with:\n```\nimport string\nimport random\ndef task_func(text, seed=None):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-156","gold":"    COLUMN_NAMES = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']\n    scaler = MinMaxScaler()\n    normalized_data = scaler.fit_transform(data)\n\n    df = pd.DataFrame(normalized_data, columns=COLUMN_NAMES)\n    df['Average'] = df.mean(axis=1)\n\n    fig, ax = plt.subplots()\n    df['Average'].plot(ax=ax)\n\n    return df, ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","pandas","sklearn","unittest"],"code_prompt":"import pandas as pd\nfrom sklearn.preprocessing import MinMaxScaler\nimport matplotlib.pyplot as plt\ndef task_func(data):\n","entry_point":"task_func"},"prompt":"Normalizes a given dataset using MinMax scaling and calculates the average of each row. This average is then added as a new column 'Average' to the resulting DataFrame. The function also visualizes these averages in a plot.\nThe function should output with:\n    DataFrame: A pandas DataFrame where data is normalized, with an additional column 'Average' representing the\n    mean of each row.\n    Axes: A matplotlib Axes object showing a bar subplot of the average values across the dataset.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nfrom sklearn.preprocessing import MinMaxScaler\nimport matplotlib.pyplot as plt\ndef task_func(data):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-239","gold":"    arr = np.array([b for (a, b) in original])\n\n    computed_stats = {\n        'mean': np.mean(arr),\n        'std': np.std(arr),\n        'min': np.min(arr),\n        'max': np.max(arr)\n    }\n    \n    # Plotting histogram and PDF\n    fig, ax = plt.subplots()\n    ax.hist(arr, density=True, alpha=0.6, bins='auto', label='Histogram')\n    \n    # Adding PDF\n    xmin, xmax = ax.get_xlim()\n    x = np.linspace(xmin, xmax, 100)\n    p = stats.norm.pdf(x, computed_stats['mean'], computed_stats['std'])\n    ax.plot(x, p, 'k', linewidth=2, label='PDF')\n    ax.set_title('Histogram with PDF')\n    ax.legend()\n    plt.close(fig)  # Close the plot to prevent display here\n    \n    return arr, computed_stats, ax","inputs":{"source":"BigCodeBench","libraries":["doctest","matplotlib","numpy","scipy","unittest"],"code_prompt":"import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy import stats\ndef task_func(original):\n","entry_point":"task_func"},"prompt":"Given a list of tuples, extract numeric values, compute basic statistics, and generate a histogram with an overlaid probability density function (PDF).\nThe function should output with:\n    np.array: A numpy array of the extracted numeric values.\n    dict: Basic statistics for the array including mean, standard deviation, minimum, and maximum.\n    Axes: A matplotlib Axes object showing the histogram with overlaid PDF. The histogram\n    is plotted with density set to True, alpha as 0.6, and bins set to 'auto' for automatic bin selection.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy import stats\ndef task_func(original):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-30","gold":"    if not os.path.isfile(file_path):\n        raise ValueError(f'{file_path} does not exist.')\n\n    with open(file_path, 'r') as f:\n        data = json.load(f)\n\n    for key in INPUT_JSON['required']:\n        if key not in data:\n            raise ValueError(f'{key} is missing from the JSON object.')\n        if not isinstance(data[key], INPUT_JSON['properties'][key]['type']):\n            raise ValueError(f'{key} is not of type {INPUT_JSON[\"properties\"][key][\"type\"]}.')\n\n    if 'email' in data and not re.fullmatch(EMAIL_REGEX, data['email']):\n        raise ValueError('Email is not valid.')\n\n    return data[attribute]","inputs":{"source":"BigCodeBench","libraries":["json","os","re","unittest"],"code_prompt":"import json\nimport os\nimport re\ndef task_func(\n    file_path,\n    attribute,\n    INPUT_JSON={\n        \"type\": \"object\",\n        \"properties\": {\n            \"name\": {\"type\": str},  \n            \"age\": {\"type\": int},   \n            \"email\": {\"type\": str}  \n        },\n        \"required\": [\"name\", \"age\", \"email\"]\n    },\n    EMAIL_REGEX=r\"^[a-z0-9]+[\\._]?[a-z0-9]+[@]\\w+[.]\\w{2,3}$\"):\n","entry_point":"task_func"},"prompt":"Validate the structure and contents of a JSON file against predefined schema rules and retrieve a specified attribute from the JSON object. Ensures that all required fields exist, match their defined types, and checks the validity of the email format using a regular expression. Errors: - Raises ValueError if the file does not exist, required attributes are missing, types do not match, or the email format is invalid.\nThe function should output with:\n    Any: The value of the specified attribute, consistent with the type defined in the JSON schema.\nYou should write self-contained code starting with:\n```\nimport json\nimport os\nimport re\ndef task_func(\n    file_path,\n    attribute,\n    INPUT_JSON={\n        \"type\": \"object\",\n        \"properties\": {\n            \"name\": {\"type\": str},  \n            \"age\": {\"type\": int},   \n            \"email\": {\"type\": str}  \n        },\n        \"required\": [\"name\", \"age\", \"email\"]\n    },\n    EMAIL_REGEX=r\"^[a-z0-9]+[\\._]?[a-z0-9]+[@]\\w+[.]\\w{2,3}$\"):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-977","gold":"\n    if seed is not None:\n        np.random.seed(seed)\n\n    if array.size == 0 or len(array.shape) != 2:\n        raise ValueError(\"Input array must be 2-dimensional and non-empty.\")\n\n    if features is not None and len(features) != array.shape[1]:\n        raise ValueError(\"Features list must match the number of columns in the array.\")\n\n    shuffled_array = np.random.permutation(array.T).T\n\n    fig, ax = plt.subplots()\n    sns.heatmap(\n        shuffled_array,\n        xticklabels=features if features is not None else np.arange(array.shape[1]) + 1,\n        ax=ax,\n    )\n\n    return ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","seaborn","unittest"],"code_prompt":"import numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\ndef task_func(array, features=None, seed=None):\n","entry_point":"task_func"},"prompt":"Shuffles the columns of a given 2D numpy array and visualizes it as a heatmap.\nNote that: Notes: This function uses the features list as labels for the heatmap's x-axis if features is provided; otherwise, it defaults to strings of the numerical labels starting from 1 up to the number of columns in the array.\nThe function should raise the exception for: ValueError: If 'features' is provided and does not match the number of columns in 'array'; and if 'array' is empty or not 2-dimensional.\nThe function should output with:\n    Axes: The matplotlib Axes object containing the heatmap.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\ndef task_func(array, features=None, seed=None):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-826","gold":"    if not os.path.exists(source_dir):\n        raise FileNotFoundError(\"The source directory does not exist.\")\n    if not os.path.exists(target_dir):\n        os.makedirs(target_dir)\n\n    moved_files_count = 0\n\n    for filename in os.listdir(source_dir):\n        if re.match(file_pattern, filename):\n            shutil.move(os.path.join(source_dir, filename), os.path.join(target_dir, filename))\n            moved_files_count += 1\n\n    return moved_files_count","inputs":{"source":"BigCodeBench","libraries":["faker","os","re","shutil","tempfile","unittest"],"code_prompt":"import re\nimport os\nimport shutil\ndef task_func(source_dir, target_dir, file_pattern=r'\\b[A-Za-z0-9]+\\.(txt|doc|docx)\\b'):\n","entry_point":"task_func"},"prompt":"Move files from the source directory to the target directory based on a specified pattern. This function iterates through all files in the source directory, and if a file's name matches the specified pattern, it is moved to the target directory.\nThe function should output with:\n    moved_files_count (int): The number of files that were successfully moved from the source directory to the target directory.\nYou should write self-contained code starting with:\n```\nimport re\nimport os\nimport shutil\ndef task_func(source_dir, target_dir, file_pattern=r'\\b[A-Za-z0-9]+\\.(txt|doc|docx)\\b'):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-757","gold":"    vectorized_reverse = np.vectorize(lambda s: '.'.join(s.split('.')[::-1]))\n    \n    now = datetime.datetime.now()\n    \n    return vectorized_reverse(arr)","inputs":{"source":"BigCodeBench","libraries":["datetime","numpy","re","unittest"],"code_prompt":"import numpy as np\nimport datetime\ndef task_func(arr):\n","entry_point":"task_func"},"prompt":"Reverse the order of words separated by. \"\" in all strings of a numpy array.\nThe function should output with:\n    numpy.ndarray: The numpy array with the strings reversed.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport datetime\ndef task_func(arr):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-530","gold":"    if df.empty:\n        raise ValueError(\"Input data cannot be empty.\")\n    if any(df[\"age\"] < 0):\n        raise ValueError(\"Invalid age: age cannot be less than 0.\")\n\n    df[\"age\"] = df[\"age\"].apply(np.floor).astype(int)\n\n    duplicate_names = (\n        df[\"name\"].value_counts()[df[\"name\"].value_counts() > 1].index.tolist()\n    )\n    duplicates_df = df[df[\"name\"].isin(duplicate_names)]\n    duplicates_counter = Counter(duplicates_df[\"age\"])\n\n    if duplicates_counter:\n        min_age = duplicates_df[\"age\"].min() - 0.5\n        max_age = duplicates_df[\"age\"].max() + 0.5\n        bins = np.arange(min_age, max_age + 1)\n        ax = sns.histplot(duplicates_df[\"age\"], bins=bins)\n        plt.xlabel(\"Age\")\n        plt.ylabel(\"Count\")\n        plt.title(\"Distribution of Ages for Duplicate Names\")\n    else:\n        ax = None\n\n    return duplicates_counter, ax","inputs":{"source":"BigCodeBench","libraries":["collections","matplotlib","numpy","pandas","seaborn","unittest"],"code_prompt":"import pandas as pd\nimport numpy as np\nfrom collections import Counter\nimport seaborn as sns\nimport matplotlib.pyplot as plt\ndef task_func(df: pd.DataFrame) -> (Counter, plt.Axes):\n","entry_point":"task_func"},"prompt":"Identify duplicate entries in a DataFrame and record the age distribution for the duplicate names. This function takes a DataFrame with 'name' and 'age' columns. If age is provided as floats, they will be rounded down to the nearest integer. Age must not be negative, otherwise the function raises ValueError. Then, the function identifies duplicate names and records the age distribution. It returns a Counter object with the age distribution and a histogram plot showing the distribution of ages for duplicate names, with age on the x-axis and count on the y-axis. Bins are calculated based on the minimum and maximum ages found among the duplicates, adjusted by .5 to ensure that integer ages fall squarely within bins.\nThe function should raise the exception for: ValueError: If the DataFrame is empty or if age is negative.\nThe function should output with:\n    Counter: Age distribution among duplicate names.\n    plt.Axes or None: Histogram plot displaying age distribution, or None if there are no duplicates.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport numpy as np\nfrom collections import Counter\nimport seaborn as sns\nimport matplotlib.pyplot as plt\ndef task_func(df: pd.DataFrame) -> (Counter, plt.Axes):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-780","gold":"\n    if not isinstance(articles, list):\n        raise TypeError(\"articles should be a list of dictionaries.\")\n\n    if not all(isinstance(item, dict) for item in articles):\n        raise TypeError(\"articles should be a list of dictionaries.\")\n\n    if len(articles) == 0:\n        raise ValueError(\"input articles list should contain at least one article.\")\n\n    if any(not sorted(dic.keys()) == ['category', 'id', 'published_time', 'title', 'title_url'] for dic in articles):\n        raise ValueError(\n            \"input dictionaries must contain the following keys: 'category', 'id', 'title', 'title_url', 'published_time'\")\n\n    tz = pytz.timezone(timezone)\n    for article in articles:\n        article['published_time'] = pd.to_datetime(article['published_time']).astimezone(tz)\n\n    df = pd.DataFrame(articles)\n    df['published_time'] = df['published_time'].dt.hour\n\n    analysis_df = df.groupby('category')['published_time'].agg(['count', 'mean', 'min', 'max'])\n\n    return analysis_df","inputs":{"source":"BigCodeBench","libraries":["datetime","pandas","pytz","unittest"],"code_prompt":"import pandas as pd\nimport pytz\ndef task_func(articles, timezone):\n","entry_point":"task_func"},"prompt":"Analyze the publication times of a list of articles: 1) Convert 'published_time' to a specified timezone 2) Group articles by 'category' 3) For each category, calculate the count, mean, min, max publication times only considering the hour.\nThe function should raise the exception for: ValueError: If dictionary keys do not match the requirements. TypeError: If articles is not a list of dictionaries. ValueError: If an empty list is passed as articles.\nThe function should output with:\n    DataFrame: A pandas DataFrame with the count, mean, min, max publication hour for each category.\n    The category is the index of the DataFrame.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport pytz\ndef task_func(articles, timezone):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-901","gold":"    if not d:  # Check if the input list is empty\n        return pd.DataFrame(columns=['x', 'y', 'z'])  # Return an empty DataFrame with specified columns\n    \n    df = pd.DataFrame(d)\n    scaler = MinMaxScaler()\n    scaled_df = pd.DataFrame(scaler.fit_transform(df[['x', 'y', 'z']]), columns=['x', 'y', 'z'])\n\n    return scaled_df","inputs":{"source":"BigCodeBench","libraries":["pandas","sklearn","unittest"],"code_prompt":"import pandas as pd\nfrom sklearn.preprocessing import MinMaxScaler\n# Updated function to handle empty input list\ndef task_func(d):\n","entry_point":"task_func"},"prompt":"Scale all values with the keys \"x,\" \"y\" and \"z\" from a list of dictionaries \"d\" with MinMaxScaler. >>> data = [{'x': -1, 'y': 0, 'z': 5}, {'x': 3, 'y': -15, 'z': 0}, {'x': 0, 'y': 1, 'z': -7}] >>> print(task_func(data)) x       y         z 0  0.00  0.9375  1.000000 1  1.00  0.0000  0.583333 2  0.25  1.0000  0.000000\nThe function should output with:\n    DataFrame: A pandas DataFrame with scaled values.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nfrom sklearn.preprocessing import MinMaxScaler\n# Updated function to handle empty input list\ndef task_func(d):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-469","gold":"    if not student_grades:\n        raise ValueError(\"student_grades cannot be empty\")\n    possible_grades = [*dict.fromkeys([g.upper() for g in possible_grades])]\n    grade_counts = dict(Counter([g.upper() for g in student_grades]))\n    report_data = {grade: grade_counts.get(grade, 0) for grade in possible_grades}\n    report_df = pd.DataFrame.from_dict(report_data, orient=\"index\", columns=[\"Count\"])\n    report_df.index.name = \"Grade\"\n\n    ax = report_df.plot(kind=\"bar\", legend=False, title=\"Grade Distribution\")\n    ax.set_ylabel(\"Number of Students\")\n    ax.set_xlabel(\"Grade\")\n\n    plt.tight_layout()\n\n    return report_df, ax","inputs":{"source":"BigCodeBench","libraries":["collections","matplotlib","pandas","unittest"],"code_prompt":"import pandas as pd\nimport matplotlib.pyplot as plt\nfrom collections import Counter\ndef task_func(student_grades, possible_grades=[\"A\", \"B\", \"C\", \"D\", \"F\"]):\n","entry_point":"task_func"},"prompt":"Create a report on students' grades in a class, including a count of each grade out of all possible grades and a bar chart. Note: Grades are case-insensitive but whitespace-sensitive. Those not in possible grades are ignored.\nThe function should output with:\n    Tuple[DataFrame, Axes]:\n    A pandas DataFrame with 'Grade' as the named index and their 'Count' as values.\n    A bar chart plot (matplotlib's Axes object) visualizing 'Grade Distribution', with 'Grade' on the\n    x-axis and 'Number of Students' on the y-axis.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom collections import Counter\ndef task_func(student_grades, possible_grades=[\"A\", \"B\", \"C\", \"D\", \"F\"]):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-603","gold":"    combined_matrix = np.concatenate((matrix1, matrix2), axis=1)\n    df = pd.DataFrame(combined_matrix)\n    return df.to_string(index=False, header=False)","inputs":{"source":"BigCodeBench","libraries":["numpy","pandas","re","unittest"],"code_prompt":"import numpy as np\nimport pandas as pd\ndef task_func(matrix1, matrix2):\n","entry_point":"task_func"},"prompt":"Connects two 2D numeric arrays (matrices) along the second axis (columns), converts them into a Pandas DataFrame, and returns a string representation of the DataFrame.\nThe function should output with:\n    str: The string representation of the DataFrame without the index and header.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport pandas as pd\ndef task_func(matrix1, matrix2):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-252","gold":"    fig, ax = plt.subplots()\n    for series, label, color in zip_longest(data, labels, COLORS, fillvalue='black'):\n        ax.plot(series, label=label, color=color)\n        \n    ax.legend()\n    return ax","inputs":{"source":"BigCodeBench","libraries":["doctest","itertools","matplotlib","unittest"],"code_prompt":"import matplotlib.pyplot as plt\nfrom itertools import zip_longest\n# Constants\nCOLORS = ['red', 'green', 'blue', 'yellow', 'purple']\ndef task_func(data, labels):\n","entry_point":"task_func"},"prompt":"Plot a list of data with different colors. If there are more data series than the predefined colors, the function cycles through the colors. In case of even more series than colors + labels, 'black' is used.\nThe function should output with:\n    matplotlib.axes.Axes: The Axes object of the plot.\nYou should write self-contained code starting with:\n```\nimport matplotlib.pyplot as plt\nfrom itertools import zip_longest\n# Constants\nCOLORS = ['red', 'green', 'blue', 'yellow', 'purple']\ndef task_func(data, labels):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-915","gold":"    # Calculate Z-Scores for the 'closing_price' column\n    df['Z_score'] = zscore(df['closing_price'])\n    \n    # Identify outliers based on Z-Score threshold\n    outliers = df[np.abs(df['Z_score']) > z_threshold]\n    \n    # Create the plot\n    fig, ax = plt.subplots(figsize=(10, 5))\n    ax.plot(df['closing_price'], color='blue', label='Normal')\n    ax.plot(outliers['closing_price'], linestyle='none', marker='X', color='red', markersize=12, label='Outlier')\n    ax.set_xlabel('Index')\n    ax.set_ylabel('Closing Price')\n    ax.set_title('Outliers in Closing Prices')\n    ax.legend(loc='best')\n    \n    return outliers, ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","pandas","scipy","unittest"],"code_prompt":"import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.stats import zscore\ndef task_func(df, z_threshold=2):\n","entry_point":"task_func"},"prompt":"Identifies and plots outliers in the 'closing_price' column of a given DataFrame using the Z-Score method. Constants: - Z-Score threshold for identifying outliers is customizable via the 'z_threshold' parameter. >>> df2 = pd.DataFrame({ ...     'closing_price': [10, 20, 30, 40, 50, 100] ... }) >>> outliers2, plot2 = task_func(df2, z_threshold=1.5)\nThe function should output with:\n    tuple: A tuple containing the following elements:\n    pandas.DataFrame: A DataFrame containing the outliers in the 'closing_price' column.\n    matplotlib.axes._axes.Axes: The plot object displaying the outliers, if x-axis label 'Index', y-axis label 'Closing Price', and title 'Outliers in Closing Prices'.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.stats import zscore\ndef task_func(df, z_threshold=2):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-177","gold":"    # Ensure the DataFrame contains the required columns\n    if \"Title\" not in df.columns or \"Content\" not in df.columns:\n        raise ValueError(\"DataFrame must include 'Title' and 'Content' columns.\")\n    pattern = re.compile(r'(like|what)', re.IGNORECASE)\n    interesting_articles = df[df['Title'].apply(lambda x: bool(pattern.search(x)))]\n\n    word_freq = {}\n    if interesting_articles.empty:\n        return word_freq\n\n    for content in interesting_articles['Content']:\n        tokens = nltk.word_tokenize(content)\n        for token in tokens:\n            if token not in punctuation:\n                if token not in word_freq:\n                    word_freq[token] = 1\n                else:\n                    word_freq[token] += 1\n\n    return word_freq","inputs":{"source":"BigCodeBench","libraries":["nltk","pandas","re","string","unittest"],"code_prompt":"import re\nimport nltk\nfrom string import punctuation\ndef task_func(df):\n","entry_point":"task_func"},"prompt":"Extracts articles whose titles contain specific case-insensitive keywords (\"like\" or \"what\") from a DataFrame and analyzes the frequency of each word in the content of these articles, excluding punctuation.\nThe function should raise the exception for: ValueError: If the DataFrame is empty or does not contain the necessary columns 'Title' and 'Content'.\nThe function should output with:\n    dict: A dictionary with keys as words and values as their corresponding frequency, excluding any punctuation marks.\nYou should write self-contained code starting with:\n```\nimport re\nimport nltk\nfrom string import punctuation\ndef task_func(df):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-793","gold":"    if l is None:\n        l = ELEMENTS.copy()  # Use a copy to avoid modifying the original list\n    random.shuffle(l)\n    arr = np.array(l)\n    arr = np.concatenate((arr[3:], arr[:3]))\n    return arr","inputs":{"source":"BigCodeBench","libraries":["numpy","random","unittest"],"code_prompt":"import numpy as np\nimport random\n# Constants\nELEMENTS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']\ndef task_func(l=None):\n","entry_point":"task_func"},"prompt":"Create a numeric array from a list \"l\" and move the first 3 elements to the end of the array.\nThe function should output with:\n    arr (numpy.ndarray): The processed array with the first three elements moved to the end.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport random\n# Constants\nELEMENTS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']\ndef task_func(l=None):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-304","gold":"\n    # Data preparation\n\n    if df.empty:\n        return 0,0\n\n    df['Date'] = pd.to_datetime(df['Date'])\n    df = pd.concat([df['Date'], df['Value'].apply(pd.Series)], axis=1)\n    \n    # Performing PCA\n    pca = PCA()\n    pca.fit(df.iloc[:,1:])\n    \n    # Extracting explained variance ratio\n    explained_variance_ratio = pca.explained_variance_ratio_\n    \n    # Creating bar chart\n    fig, ax = plt.subplots()\n    ax.bar(range(len(explained_variance_ratio)), explained_variance_ratio)\n    ax.set_title('Explained Variance Ratio of Principal Components')\n    ax.set_xlabel('Principal Component')\n    ax.set_ylabel('Explained Variance Ratio')\n    \n    return explained_variance_ratio, ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","pandas","sklearn","unittest"],"code_prompt":"import pandas as pd\nfrom sklearn.decomposition import PCA\nimport matplotlib.pyplot as plt\ndef task_func(df):\n","entry_point":"task_func"},"prompt":"Processes a DataFrame containing dates and lists of numbers. It converts the lists into separate columns, performs Principal Component Analysis (PCA), and returns the explained variance ratio of the principal components along with a bar chart visualizing this ratio. Returns 0,0 if the input DataFrame is empty.\nNote that: The function use \"Explained Variance Ratio of Principal Components\" for the plot title. The function use \"Principal Component\" and \"Explained Variance Ratio\" as the xlabel and ylabel respectively.\nThe function should output with:\n    tuple: (explained_variance_ratio, ax)\n    explained_variance_ratio (ndarray): The explained variance ratio of the principal components.\n    ax (Axes): The matplotlib Axes object for the variance ratio bar chart.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nfrom sklearn.decomposition import PCA\nimport matplotlib.pyplot as plt\ndef task_func(df):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-820","gold":"    # Validate input parameters\n    if num_words < 0 or word_length < 0:\n        raise ValueError(\"num_words and word_length must be non-negative\")\n\n    random.seed(42)\n    words = [''.join(random.choice(LETTERS) for _ in range(word_length)) for _ in range(num_words)]\n    \n    return words","inputs":{"source":"BigCodeBench","libraries":["random","string","unittest"],"code_prompt":"import random\nimport string\n# Constants\nLETTERS = string.ascii_letters\ndef task_func(num_words, word_length):\n","entry_point":"task_func"},"prompt":"Create a list of random words of a certain length.\nThe function should raise the exception for: ValueError: If num_words or word_length is negative.\nThe function should output with:\n    words (list): A list of random words.\nYou should write self-contained code starting with:\n```\nimport random\nimport string\n# Constants\nLETTERS = string.ascii_letters\ndef task_func(num_words, word_length):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-954","gold":"    if n_sentences < 0:\n        raise ValueError(\"n_sentences cannot be negative.\")\n    if not vocabulary:\n        raise ValueError(\"Vocabulary cannot be empty.\")\n\n    sentences = []\n    for _ in range(n_sentences):\n        sentence = \" \".join(random.choices(vocabulary, k=10))\n        for word in target_words:\n            pattern = re.compile(re.escape(word), re.IGNORECASE)\n            sentence = pattern.sub(word.replace(\" \", \"_\"), sentence)\n        sentences.append(sentence.lower())\n    return sentences","inputs":{"source":"BigCodeBench","libraries":["random","re","unittest"],"code_prompt":"import random\nimport re\ndef task_func(target_words, n_sentences, vocabulary):\n","entry_point":"task_func"},"prompt":"Generate sentences with spaces in certain target words replaced by underscores.\nNote that: Notes: Each sentence is generated by randomly sampling 10 words with replacement from a vocabulary, then concatenating with a single whitespace. Then, if any words from the target_words list appear in these sentences, spaces within those words are replaced with underscores; here the modification is insensitive to the case of the letters. The function returns the processed sentences as a list of all lowercase strings.\nThe function should raise the exception for: ValueError: If n_sentences is negative or if the vocabulary is empty.\nThe function should output with:\n    list of str: A list of generated sentences in all lowercase, with specified words/phrases underscored.\nYou should write self-contained code starting with:\n```\nimport random\nimport re\ndef task_func(target_words, n_sentences, vocabulary):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-148","gold":"    le = LabelEncoder()\n    df[column_name] = le.fit_transform(df[column_name])\n    return df","inputs":{"source":"BigCodeBench","libraries":["pandas","sklearn","unittest"],"code_prompt":"import pandas as pd\nfrom sklearn.preprocessing import LabelEncoder\ndef task_func(df: pd.DataFrame, column_name: str) -> pd.DataFrame:\n","entry_point":"task_func"},"prompt":"Encrypt the categorical data in a specific column of a DataFrame using LabelEncoder.\nThe function should output with:\n    pd.DataFrame: The DataFrame with the encoded column.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nfrom sklearn.preprocessing import LabelEncoder\ndef task_func(df: pd.DataFrame, column_name: str) -> pd.DataFrame:\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-268","gold":"\n    keys = [random.choice(LETTERS) for _ in range(n_keys)]\n    values = list(range(1, n_values + 1))\n    return dict(collections.OrderedDict((k, values) for k in keys))","inputs":{"source":"BigCodeBench","libraries":["collections","random","unittest"],"code_prompt":"import collections\nimport random\n# Constants\nLETTERS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']\ndef task_func(n_keys, n_values):\n","entry_point":"task_func"},"prompt":"Create a Python dictionary with a specified number of keys and values.\nNote that: Keys are randomly selected from a predefined list of letters, and values are consecutive integers starting from 1. Due to the randomness in key selection, the actual keys in the dictionary may vary in each execution.\nThe function should output with:\n    dict: A Python dictionary with keys as strings and values as lists of integers.\nYou should write self-contained code starting with:\n```\nimport collections\nimport random\n# Constants\nLETTERS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']\ndef task_func(n_keys, n_values):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-428","gold":"    merged_df = pd.merge(df1, df2, on=\"id\", how=\"outer\")\n\n    # Select only numeric columns from df1 (excluding 'id')\n    numeric_features_df1 = df1.select_dtypes(\n        include=[\"float64\", \"int64\"]\n    ).columns.tolist()\n    if \"id\" in numeric_features_df1:\n        numeric_features_df1.remove(\"id\")\n\n    # Scale only the numeric features of df1\n    if not merged_df.empty and numeric_features_df1:\n        scaler = StandardScaler()\n        merged_df[numeric_features_df1] = scaler.fit_transform(\n            merged_df[numeric_features_df1]\n        )\n\n    # Pair plot only for the numeric features of df1\n    pair_plot = None\n    if numeric_features_df1:\n        pair_plot = sns.pairplot(merged_df[numeric_features_df1])\n\n    return merged_df, pair_plot","inputs":{"source":"BigCodeBench","libraries":["matplotlib","pandas","seaborn","sklearn","unittest"],"code_prompt":"import pandas as pd\nimport seaborn as sns\nfrom sklearn.preprocessing import StandardScaler\ndef task_func(df1, df2):\n","entry_point":"task_func"},"prompt":"Merge two dataframes on the 'id' column and then scale the numeric features. This function merges two dataframes via outer join on the 'id' column, and scales the merged dataframe's numeric features from df1 to have a mean of 0 and standard deviation of 1. It also returns a pair plot of the scaled features from df1.\nThe function should output with:\n    merged_df (pd.DataFrame): The partially scaled and merged dataframe.\n    pair_plot (seaborn.axisgrid.PairGrid): Pair plot of the scaled dataframe.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport seaborn as sns\nfrom sklearn.preprocessing import StandardScaler\ndef task_func(df1, df2):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-243","gold":"    if n_data_points == 0:\n        return pd.DataFrame(columns=['Value'])\n    \n    data = [round(random.uniform(MIN_VALUE, MAX_VALUE), 3) for _ in range(n_data_points)]\n    data_df = pd.DataFrame(data, columns=['Value'])\n\n    return data_df","inputs":{"source":"BigCodeBench","libraries":["pandas","random","unittest"],"code_prompt":"import pandas as pd\nimport random\n# Constants\nN_DATA_POINTS = 10000\nMIN_VALUE = 0.0\nMAX_VALUE = 10.0\ndef task_func(n_data_points=N_DATA_POINTS):\n","entry_point":"task_func"},"prompt":"Generate a random set of floating-point numbers, truncate each value to 3 decimal places, and return them in a DataFrame. The number of data points to generate can be specified. If zero, returns an empty DataFrame.\nNote that: This function use 'Value' for the column name in returned DataFrame\nThe function should output with:\n    DataFrame: A pandas DataFrame containing one column 'Value' with the generated data. Empty if n_data_points is 0.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport random\n# Constants\nN_DATA_POINTS = 10000\nMIN_VALUE = 0.0\nMAX_VALUE = 10.0\ndef task_func(n_data_points=N_DATA_POINTS):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-798","gold":"    # Check if the backup directory exists\n    if not os.path.exists(BACKUP_DIR):\n        return f'Backup directory {BACKUP_DIR} does not exist. Cannot rollback update.'\n\n    backups = sorted(os.listdir(BACKUP_DIR))\n    latest_backup = backups[-1] if backups else None\n\n    if not latest_backup:\n        return f'No backups found in {BACKUP_DIR}. Cannot rollback update.'\n\n    if os.path.exists(directory):\n        shutil.rmtree(directory)\n\n    shutil.copytree(os.path.join(BACKUP_DIR, latest_backup), directory)\n    return directory","inputs":{"source":"BigCodeBench","libraries":["os","shutil","unittest"],"code_prompt":"import os\nimport shutil\n# Constants\nBACKUP_DIR = '/tmp/backup'\ndef task_func(directory):\n","entry_point":"task_func"},"prompt":"Rollback the update of a directory by restoring it from a backup. Constants: - BACKUP_DIR: The directory where backups are stored. Default is '/tmp/backup'. >>> task_func('/tmp/nonexistent') 'Backup directory /tmp/backup does not exist. Cannot rollback update.'\nNote that: This function will return the restored directory path on successful rollback, or an error message otherwise.\nThe function should output with:\n    directory (str): The restored directory path if successful, otherwise an error message.\nYou should write self-contained code starting with:\n```\nimport os\nimport shutil\n# Constants\nBACKUP_DIR = '/tmp/backup'\ndef task_func(directory):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-802","gold":"    np.random.seed(seed)  # Ensure reproducible results\n    \n    if dimension <= 0:\n        raise ValueError(\"The dimension must be a positive integer\")\n    \n    matrix = np.random.randint(1, 101, size=(dimension, dimension))\n    flat_list = matrix.flatten().tolist()\n    \n    combinations = list(itertools.combinations(flat_list, 2))\n    \n    return matrix, flat_list","inputs":{"source":"BigCodeBench","libraries":["itertools","numpy","unittest"],"code_prompt":"import numpy as np\nimport itertools\ndef task_func(dimension, seed=42):\n","entry_point":"task_func"},"prompt":"Create a 2D numeric array (matrix) of a given dimension with random integers between 1 and 100, and a flat list of all elements in the matrix.\nThe function should output with:\n    tuple: A tuple containing:\n    A 2D numpy array of the given dimension with random integers between 1 and 100.\n    A flat list of all elements in the matrix.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport itertools\ndef task_func(dimension, seed=42):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-311","gold":"    random.seed(seed)\n    data = []\n    for list_ in list_of_lists:\n        if list_:\n            data += list_\n        else:\n            data += [random.randint(0, 100) for _ in range(size)]\n    \n    return {\n        'mean': np.mean(data),\n        'median': np.median(data),\n        'mode': stats.mode(data)[0]\n    }","inputs":{"source":"BigCodeBench","libraries":["doctest","numpy","random","scipy","unittest"],"code_prompt":"import numpy as np\nimport random\nfrom scipy import stats\ndef task_func(list_of_lists, size=5, seed=0):\n","entry_point":"task_func"},"prompt":"Calculate the mean, median, and mode of values in a list of lists. If a list is empty, fill it with SIZE (default: 5) random integers between 0 and 100, and then calculate the statistics.\nThe function should output with:\n    dict: A dictionary with the mean, median, and mode of the values.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport random\nfrom scipy import stats\ndef task_func(list_of_lists, size=5, seed=0):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-471","gold":"    words = [w.lower().strip() for w in myList]\n    word_counts = dict(Counter(words))\n    report_df = pd.DataFrame.from_dict(word_counts, orient=\"index\", columns=[\"Count\"])\n\n    return report_df","inputs":{"source":"BigCodeBench","libraries":["collections","pandas","unittest"],"code_prompt":"from collections import Counter\nimport pandas as pd\ndef task_func(myList):\n","entry_point":"task_func"},"prompt":"Count the frequency of each word in a list and return a DataFrame of words and their number.\nThe function should output with:\n    DataFrame: A pandas DataFrame with words and their counts.\nYou should write self-contained code starting with:\n```\nfrom collections import Counter\nimport pandas as pd\ndef task_func(myList):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-162","gold":"    # Splitting the words and computing their lengths\n    words = re.split(r'\\W+', text)\n    word_lengths = [len(word) for word in words if word != '']\n\n    # Plotting the histogram\n    fig, ax = plt.subplots()\n    if word_lengths:  # Check if the list is not empty\n        bins = np.arange(max(word_lengths) + 2) - 0.5\n    else:\n        bins = []  # Set bins to an empty list if no words are found\n    ax.hist(word_lengths, bins=bins, rwidth=rwidth)\n    ax.set_title(\"Distribution of Word Lengths\")\n    ax.set_xlabel(\"Word Length\")\n    ax.set_ylabel(\"Frequency\")\n\n    return ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","re","unittest"],"code_prompt":"import re\nimport matplotlib.pyplot as plt\nimport numpy as np\ndef task_func(text, rwidth=0.8):\n","entry_point":"task_func"},"prompt":"Analyzes and visualizes the distribution of word lengths in a text. The function generates a histogram subplot, which facilitates the understanding of how word lengths vary within the provided text.\nNote that: If there are no words in the input text, or all words are filtered out, the histogram will be empty as no bins will be created.\nThe function should output with:\n    matplotlib.axes.Axes: An Axes object containing the histogram of word lengths.\nYou should write self-contained code starting with:\n```\nimport re\nimport matplotlib.pyplot as plt\nimport numpy as np\ndef task_func(text, rwidth=0.8):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-212","gold":"    max_y_point = max(data, key=itemgetter(1))\n    points = np.array(data)\n    x = points[:,0]\n    y = points[:,1]\n\n    fig, ax = plt.subplots()\n    ax.scatter(x, y, label='Points')\n    ax.scatter(*max_y_point, color='red', label='Max Y Point')\n    ax.set_xlabel('x')\n    ax.set_ylabel('y')\n    ax.set_title('Points with Max Y Point Highlighted')\n    ax.legend()\n    return ax, max_y_point","inputs":{"source":"BigCodeBench","libraries":["doctest","matplotlib","numpy","operator","unittest"],"code_prompt":"import numpy as np\nfrom operator import itemgetter\nimport matplotlib.pyplot as plt\ndef task_func(data):\n","entry_point":"task_func"},"prompt":"Draw a scatter plot of dots and mark the point with the maximum y-value. Return the axes object as well as the maximum y-value point.\nThe function should output with:\n    matplotlib.axes.Axes: Axes object with the scatter plot, with the x-axis labeled 'x', the y-axis labeled 'y', and the title 'Points with Max Y Point Highlighted'.\n    tuple: The point with the maximum y-value.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nfrom operator import itemgetter\nimport matplotlib.pyplot as plt\ndef task_func(data):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-967","gold":"    X = np.linspace(x_range[0], x_range[1], num_points)\n    y = func(X)\n    y_int = integrate.cumulative_trapezoid(y, X, initial=0)\n\n    fig, ax = plt.subplots()\n    ax.plot(X, y, label=f\"{func.__name__}(x)\")\n    ax.plot(X, y_int, label=f\"Integral of {func.__name__}(x)\")\n    ax.legend()\n\n    return ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","scipy","unittest"],"code_prompt":"import numpy as np\nfrom scipy import integrate\nimport matplotlib.pyplot as plt\ndef task_func(func, x_range=(-2, 2), num_points=1000):\n","entry_point":"task_func"},"prompt":"Calculates and plots both a given function and its cumulative integral over a specified range, using a linearly spaced range of x-values.\nNote that: The plot includes a legend and labels for the x and y axes that include the function's name.\nThe function should output with:\n    matplotlib.axes.Axes: The Axes object containing the plots of the function and its integral.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nfrom scipy import integrate\nimport matplotlib.pyplot as plt\ndef task_func(func, x_range=(-2, 2), num_points=1000):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-57","gold":"    data = pd.read_csv(csv_file_path)\n    corr = data.corr().round(2)\n    plt.figure(figsize=(10, 8))\n    sns.heatmap(corr, annot=True, cmap='coolwarm', cbar=True)\n    plt.title(title)\n    return corr, plt.gca()","inputs":{"source":"BigCodeBench","libraries":["matplotlib","os","pandas","seaborn","shutil","unittest"],"code_prompt":"import pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\ndef task_func(csv_file_path: str, title: str):\n","entry_point":"task_func"},"prompt":"Create a heatmap of the correlation matrix of a DataFrame built from a CSV file. Round each correlation to 2 decimals.\nThe function should output with:\n    DataFrame: correlation dataframe where each row and each column correspond to a specific column.\n    matplotlib.axes.Axes: The Axes object of the plotted data.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\ndef task_func(csv_file_path: str, title: str):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-152","gold":"    students_data = []\n\n    for student in STUDENTS:\n        grades = [randint(0, 100) for _ in COURSES]\n        average_grade = np.mean(grades)\n        students_data.append([student] + grades + [average_grade])\n\n    columns = ['Name'] + COURSES + ['Average Grade']\n    grades_df = pd.DataFrame(students_data, columns=columns)\n\n    return grades_df","inputs":{"source":"BigCodeBench","libraries":["numpy","pandas","random","unittest"],"code_prompt":"import pandas as pd\nimport numpy as np\nfrom random import randint\n# Constants\nSTUDENTS = ['Joe', 'Amy', 'Mark', 'Sara', 'John', 'Emily', 'Zoe', 'Matt']\nCOURSES = ['Math', 'Physics', 'Chemistry', 'Biology', 'English', 'History', 'Geography', 'Computer Science']\ndef task_func():\n","entry_point":"task_func"},"prompt":"Generates a DataFrame containing random grades for a predefined list of students across a set of courses. Each student will have one grade per course and an average grade calculated across all courses.\nNote that: The grades are randomly generated for each course using a uniform distribution between 0 and 100.\nThe function should output with:\n    DataFrame: A pandas DataFrame with columns for each student's name, their grades for each course,\n    and their average grade across all courses.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport numpy as np\nfrom random import randint\n# Constants\nSTUDENTS = ['Joe', 'Amy', 'Mark', 'Sara', 'John', 'Emily', 'Zoe', 'Matt']\nCOURSES = ['Math', 'Physics', 'Chemistry', 'Biology', 'English', 'History', 'Geography', 'Computer Science']\ndef task_func():\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-380","gold":"    for filename in os.listdir(directory):\n        match = re.search(r'\\.(.*?)$', filename)\n        if match:\n            ext_dir = os.path.join(directory, match.group(1))\n            if not os.path.exists(ext_dir):\n                os.mkdir(ext_dir)\n            shutil.move(os.path.join(directory, filename), ext_dir)","inputs":{"source":"BigCodeBench","libraries":["doctest","os","re","shutil","tempfile","unittest"],"code_prompt":"import re\nimport os\nimport shutil\ndef task_func(directory):\n","entry_point":"task_func"},"prompt":"Arrange files in a directory by their extensions. Create a new directory for each extension and move the files to the corresponding directories.\nThe function should output with:\n    None\nYou should write self-contained code starting with:\n```\nimport re\nimport os\nimport shutil\ndef task_func(directory):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-253","gold":"\n    x = np.linspace(0, 2 * np.pi, 1000)\n    y = np.sin(random.randint(1, 10)*x)\n\n    color = random.choice(COLORS)\n    ax.plot(x, y, color=color)\n    ax.set_rlabel_position(random.randint(0, 180))\n\n    return color","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","random","unittest"],"code_prompt":"import numpy as np\nimport random\n# Constants\nCOLORS = ['b', 'g', 'r', 'c', 'm', 'y', 'k']\ndef task_func(ax):\n","entry_point":"task_func"},"prompt":"Generate a random sine wave function and draw it on a provided matplotlib polar subplot 'ax'. The function randomly selects a color from a predefined list and sets a random position for radial labels.\nThe function should output with:\n    str: The color code (as a string) of the plotted function.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport random\n# Constants\nCOLORS = ['b', 'g', 'r', 'c', 'm', 'y', 'k']\ndef task_func(ax):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-246","gold":"    np.random.seed(seed)\n    sine_wave_series = []\n\n    if n_waves < 1:\n        return sine_wave_series, np.array([]), None\n\n    for frequency in range(1, n_waves+1):\n        wave = np.sin(frequency * ANGLES)\n        sine_wave_series.append(wave)\n\n    fft_data = fft(np.sum(sine_wave_series, axis=0))\n    _, ax = plt.subplots()\n    ax.hist(np.abs(fft_data))\n\n    return sine_wave_series, fft_data, ax","inputs":{"source":"BigCodeBench","libraries":["doctest","matplotlib","numpy","scipy","unittest"],"code_prompt":"import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.fft import fft\nANGLES = np.arange(0, 2*np.pi, 0.01)\ndef task_func(n_waves, seed=0):\n","entry_point":"task_func"},"prompt":"Generate a series of n sine waves with increasing frequency with a fidelity of 0.01 radians as provided by the ANGLES array. The amplitude of each wave is 1. The function returns a list of numpy arrays with the y values of the sine waves. Additionally, calculate the Fast Fourier Transform (FFT) of the mixed signal and plot the histogram of the magnitude of the FFT data. If n_waves is less than 1, return an empty list for the sine waves, an empty array for the FFT data, and None for the axes object.\nThe function should output with:\n    list: A list of numpy arrays with the y values of the sine waves.\n    np.array: FFT data.\n    plt.Axes: The axes object of the plot.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.fft import fft\nANGLES = np.arange(0, 2*np.pi, 0.01)\ndef task_func(n_waves, seed=0):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-338","gold":"    random.seed(seed)\n    random_patterns = []\n\n    for element in elements:\n        random_str = ''.join(random.choices(string.ascii_letters + string.digits, k=5))\n        pattern = '% {}%'.format(random_str)\n        random_patterns.append(pattern)\n\n    # Histogram of character occurrences\n    char_count = {}\n    for pattern in random_patterns:\n        for char in pattern:\n            if char in char_count:\n                char_count[char] += 1\n            else:\n                char_count[char] = 1\n            \n    # Getting the axes object for the histogram plot\n    _, ax = plt.subplots()\n    ax.bar(char_count.keys(), char_count.values())\n\n    return random_patterns, ax, char_count","inputs":{"source":"BigCodeBench","libraries":["doctest","matplotlib","random","string","unittest"],"code_prompt":"import random\nimport string\nfrom matplotlib import pyplot as plt\ndef task_func(elements, seed=100):\n","entry_point":"task_func"},"prompt":"Format each string in the given list \"elements\" into a pattern \"% {0}%\", where {0} is a randomly generated alphanumeric string of length 5. Additionally, return the plot axes of an histogram of the occurrence of each character across all the strings and a dictionary containing the count of each character in all the formatted strings.\nThe function should output with:\n    List[str]: A list of elements formatted with random patterns.\n    plt.Axes: The axes object of the histogram plot.\n    dict: A dictionary containing the count of each character in the formatted strings.\nYou should write self-contained code starting with:\n```\nimport random\nimport string\nfrom matplotlib import pyplot as plt\ndef task_func(elements, seed=100):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-768","gold":"\n    if not os.path.isdir(dir_path):\n        raise ValueError(\"Specified directory does not exist.\")\n\n    result = {}\n    file_paths = glob.glob(f'{dir_path}/**/*.txt', recursive=True)\n    for file_path in file_paths:\n        with open(file_path, 'r') as file:\n            content = file.read()\n        matches = re.findall(r'\\berror\\b', content, re.IGNORECASE)\n        # Always set the file's count in the result dictionary, even if it's 0\n        result[os.path.relpath(file_path, dir_path)] = len(matches)\n\n    return result","inputs":{"source":"BigCodeBench","libraries":["glob","os","re","shutil","tempfile","unittest"],"code_prompt":"import re\nimport os\nimport glob\ndef task_func(dir_path):\n","entry_point":"task_func"},"prompt":"Search for occurrences of the word \"error\" in all text files within a specified directory and its subdirectories. The function specifically searches for the word \"error\" in text files (with the extension \".txt\"). This function is NOT case sensitive, e.g. also \"ERROr\" will be counted.\nThe function should raise the exception for: ValueError: If directory in dir_path does not exist.\nThe function should output with:\n    dict: A dictionary with relative file paths as keys and the count of\n    occurrences of the word \"error\" as values.\nYou should write self-contained code starting with:\n```\nimport re\nimport os\nimport glob\ndef task_func(dir_path):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-707","gold":"    df['IntCol'] = np.log10(df['IntCol'])\n\n    # Convert 'IntCol' column to a list and write it to a JSON file\n    int_col_list = df['IntCol'].tolist()\n    with open('IntCol.json', 'w') as json_file:\n        json.dump(int_col_list, json_file)\n\n    return df","inputs":{"source":"BigCodeBench","libraries":["json","numpy","os","pandas","unittest"],"code_prompt":"import json\nimport numpy as np\ndef task_func(df):\n","entry_point":"task_func"},"prompt":"Given a DataFrame with random values and an 'IntCol' column, transform the 'IntCol' column by a logarithm (base 10) and write it to a `IntCol.json` file as a list. Also return the DataFrame.\nThe function should output with:\n    df (DataFrame): A pandas DataFrame to describe the transformed data.\nYou should write self-contained code starting with:\n```\nimport json\nimport numpy as np\ndef task_func(df):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-298","gold":"    df['Date'] = pd.to_datetime(df['Date'])\n    df = pd.concat([df['Date'], df['Value'].apply(pd.Series)], axis=1)\n    \n    scaler = StandardScaler()\n    df.iloc[:,1:] = scaler.fit_transform(df.iloc[:,1:])\n    \n    if plot:\n        plt.figure()\n        ax = df.set_index('Date').plot(kind='bar', stacked=True)\n        plt.title('Scaled Values Over Time')\n        plt.xlabel('Date')\n        plt.ylabel('Scaled Value')\n        return df, ax\n\n    \n    return df","inputs":{"source":"BigCodeBench","libraries":["matplotlib","pandas","sklearn","unittest"],"code_prompt":"import pandas as pd\nfrom sklearn.preprocessing import StandardScaler\nimport matplotlib.pyplot as plt\n# Constants\nCOLUMNS = ['Date', 'Value']\ndef task_func(df, plot=False):\n","entry_point":"task_func"},"prompt":"Splits a list in the 'Value' column of a DataFrame into several columns, scales these columns using StandardScaler, and optionally returned the scaled data using a bar chart. The 'Date' column is converted to datetime and used as the index in the plot.\nNote that: This function use \"Scaled Values Over Time\" for the plot title. This function use \"Date\" and \"Scaled Value\" as the xlabel and ylabel respectively.\nThe function should raise the exception for: This function will raise KeyError if the DataFrame does not have the 'Date' and 'Value' columns.\nThe function should output with:\n    DataFrame: A pandas DataFrame with the 'Date' column and additional columns for each element in the original 'Value' list,\n    where these columns contain the scaled values.\n    Axes (optional): A matplotlib Axes object containing the bar chart, returned if 'plot' is True.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nfrom sklearn.preprocessing import StandardScaler\nimport matplotlib.pyplot as plt\n# Constants\nCOLUMNS = ['Date', 'Value']\ndef task_func(df, plot=False):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-823","gold":"    delay_times = []\n\n    for _ in range(samples):\n        t1 = time.time()\n        time.sleep(delay)\n        t2 = time.time()\n        delay_times.append(t2 - t1)\n\n    delay_times = np.array(delay_times)\n\n    mean = np.mean(delay_times)\n    std = np.std(delay_times)\n\n    return mean, std","inputs":{"source":"BigCodeBench","libraries":["numpy","time","unittest"],"code_prompt":"import time\nimport numpy as np\ndef task_func(samples=10, delay=0.1):\n","entry_point":"task_func"},"prompt":"Make a delay for a given amount of time for a specified number of samples, measure the actual delay and calculate the statistical properties of the delay times.\nThe function should output with:\n    tuple: The mean and standard deviation of the delay times.\nYou should write self-contained code starting with:\n```\nimport time\nimport numpy as np\ndef task_func(samples=10, delay=0.1):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-317","gold":"    pattern = r'\\[.*?\\]'\n    text = re.sub(pattern, '', example_str)\n    if not text.strip():\n        return {}\n\n    tfidf_vectorizer = TfidfVectorizer()\n    tfidf_matrix = tfidf_vectorizer.fit_transform([text])\n    feature_names = tfidf_vectorizer.get_feature_names_out()\n    tfidf_scores = dict(zip(feature_names, np.squeeze(tfidf_matrix.toarray())))\n\n    return tfidf_scores","inputs":{"source":"BigCodeBench","libraries":["doctest","numpy","re","sklearn","unittest"],"code_prompt":"import numpy as np\nfrom sklearn.feature_extraction.text import TfidfVectorizer\nimport re\ndef task_func(example_str):\n","entry_point":"task_func"},"prompt":"Extract all texts not enclosed in square brackets into a string and calculate the TF-IDF values which are returned as a dictionary.\nThe function should output with:\n    dict: A dictionary with words as keys and TF-IDF scores as values.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nfrom sklearn.feature_extraction.text import TfidfVectorizer\nimport re\ndef task_func(example_str):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-416","gold":"    df = pd.DataFrame(data)\n    if column in df.columns:\n        df = df.drop(columns=column)\n\n    df = df.select_dtypes(include=[\"number\"])\n\n    if df.empty:\n        return None\n\n    return sns.heatmap(df.corr())","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","pandas","seaborn","unittest"],"code_prompt":"import pandas as pd\nimport seaborn as sns\ndef task_func(data, column=\"c\"):\n","entry_point":"task_func"},"prompt":"Removes a column from a given data dictionary and creates a heatmap of the correlation matrix of the remaining data. Non-numeric columns are excluded from the heatmap. If the data is empty or has no numeric columns, the function returns None.\nThe function should output with:\n    matplotlib.axes._axes.Axes or None: The Axes object of the heatmap\n    or None if the heatmap is not generated.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport seaborn as sns\ndef task_func(data, column=\"c\"):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-31","gold":"    words = text.split()\n    dollar_words = [\n        word\n        for word in words\n        if word.startswith(\"$\")\n        and not all(c in PUNCTUATION for c in word)\n        and len(word) > 1\n    ]\n    freq = nltk.FreqDist(dollar_words)\n    if not freq:  # If frequency distribution is empty, return None\n        return None\n    plt.figure(figsize=(10, 5))\n    sns.barplot(x=freq.keys(), y=freq.values())\n    return plt.gca()","inputs":{"source":"BigCodeBench","libraries":["matplotlib","nltk","seaborn","string","unittest"],"code_prompt":"import nltk\nfrom string import punctuation\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n# Constants\nPUNCTUATION = set(punctuation)\ndef task_func(text):\n","entry_point":"task_func"},"prompt":"Draw a bar chart of the frequency of words in a text beginning with the \"$\" character. Words that start with the '$' character but consist only of punctuation (e.g., '$!$' and '$.$') are not included in the frequency count. - If there is no word respecting the above conditions, the plot should be None. - The barplot x words on the x-axis and frequencies on the y-axis.\nThe function should output with:\n    matplotlib.axes._axes.Axes: The plot showing the frequency of words beginning with the '$' character.\nYou should write self-contained code starting with:\n```\nimport nltk\nfrom string import punctuation\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n# Constants\nPUNCTUATION = set(punctuation)\ndef task_func(text):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-1097","gold":"    # Constants\n    PUNCTUATION = set(punctuation)\n\n    # Remove URLs\n    text = re.sub('http[s]?://\\S+', '', text)\n\n    # Remove punctuation\n    text = re.sub('[{}]'.format(re.escape(''.join(PUNCTUATION))), '', text)\n\n    # Tokenize the text\n    words = text.split()\n\n    # Remove stopwords\n    cleaned_words = [word for word in words if word.lower() not in PREDEFINED_STOPWORDS]\n\n    return ' '.join(cleaned_words)","inputs":{"source":"BigCodeBench","libraries":["re","string","unittest"],"code_prompt":"import re\nfrom string import punctuation\n# Predefined list of common stopwords\nPREDEFINED_STOPWORDS = {\n    \"i\", \"me\", \"my\", \"myself\", \"we\", \"our\", \"ours\", \"ourselves\", \"you\", \"your\", \"yours\", \n    \"yourself\", \"yourselves\", \"he\", \"him\", \"his\", \"himself\", \"she\", \"her\", \"hers\", \n    \"herself\", \"it\", \"its\", \"itself\", \"they\", \"them\", \"their\", \"theirs\", \"themselves\", \n    \"what\", \"which\", \"who\", \"whom\", \"this\", \"that\", \"these\", \"those\", \"am\", \"is\", \"are\", \n    \"was\", \"were\", \"be\", \"been\", \"being\", \"have\", \"has\", \"had\", \"having\", \"do\", \"does\", \n    \"did\", \"doing\", \"a\", \"an\", \"the\", \"and\", \"but\", \"if\", \"or\", \"because\", \"as\", \"until\", \n    \"while\", \"of\", \"at\", \"by\", \"for\", \"with\", \"about\", \"against\", \"between\", \"into\", \n    \"through\", \"during\", \"before\", \"after\", \"above\", \"below\", \"to\", \"from\", \"up\", \"down\", \n    \"in\", \"out\", \"on\", \"off\", \"over\", \"under\", \"again\", \"further\", \"then\", \"once\", \"more\"\n}\ndef task_func(text):\n","entry_point":"task_func"},"prompt":"Clean the specified text by removing URLs, stopwords, and punctuation.\nThe function should output with:\n    str: The cleaned text with URLs, predefined stopwords, and punctuation removed.\nYou should write self-contained code starting with:\n```\nimport re\nfrom string import punctuation\n# Predefined list of common stopwords\nPREDEFINED_STOPWORDS = {\n    \"i\", \"me\", \"my\", \"myself\", \"we\", \"our\", \"ours\", \"ourselves\", \"you\", \"your\", \"yours\", \n    \"yourself\", \"yourselves\", \"he\", \"him\", \"his\", \"himself\", \"she\", \"her\", \"hers\", \n    \"herself\", \"it\", \"its\", \"itself\", \"they\", \"them\", \"their\", \"theirs\", \"themselves\", \n    \"what\", \"which\", \"who\", \"whom\", \"this\", \"that\", \"these\", \"those\", \"am\", \"is\", \"are\", \n    \"was\", \"were\", \"be\", \"been\", \"being\", \"have\", \"has\", \"had\", \"having\", \"do\", \"does\", \n    \"did\", \"doing\", \"a\", \"an\", \"the\", \"and\", \"but\", \"if\", \"or\", \"because\", \"as\", \"until\", \n    \"while\", \"of\", \"at\", \"by\", \"for\", \"with\", \"about\", \"against\", \"between\", \"into\", \n    \"through\", \"during\", \"before\", \"after\", \"above\", \"below\", \"to\", \"from\", \"up\", \"down\", \n    \"in\", \"out\", \"on\", \"off\", \"over\", \"under\", \"again\", \"further\", \"then\", \"once\", \"more\"\n}\ndef task_func(text):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-1001","gold":"    df = pd.read_csv(csv_file_path)\n    mean = df[\"column1\"].mean()\n    std = df[\"column1\"].std()\n    df[\"column1_normalized\"] = (df[\"column1\"] - mean) / std\n\n    # Creating a figure and axes\n    _, ax = plt.subplots()\n    # Plotting on the created axes\n    ax.plot(df[\"column1_normalized\"])\n    title = \"%*s : %*s\" % (20, \"Plot Title\", 20, \"Normalized Column 1\")\n    xlabel = \"%*s : %*s\" % (20, \"Index\", 20, \"Normalized Value\")\n    ylabel = \"%*s : %*s\" % (20, \"Frequency\", 20, \"Normalized Value\")\n    ax.set_title(title)\n    ax.set_xlabel(xlabel)\n    ax.set_ylabel(ylabel)\n\n    # Return the axes object for further manipulation\n    return ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","pandas","unittest"],"code_prompt":"import pandas as pd\nimport matplotlib.pyplot as plt\ndef task_func(csv_file_path: str):\n","entry_point":"task_func"},"prompt":"This function reads data from a CSV file, normalizes a specific column named 'column1', and then plots the normalized data. - The title is created using Python's string formatting, aligning 'Plot Title' and 'Normalized Column 1' on either side of a colon, each padded to 20 characters. - Similarly, the x-label is formatted with 'Index' and 'Normalized Value' on either side of a colon, each padded to 20 characters. - The y-label is set in the same manner, with 'Frequency' and 'Normalized Value' on either side of a colon.\nThe function should output with:\n    The matplotlib.axes.Axes object with the plot of the normalized data.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport matplotlib.pyplot as plt\ndef task_func(csv_file_path: str):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-208","gold":"    np.random.seed(seed)\n    if not isinstance(elements, int) or elements <= 0:\n        raise ValueError(\"Element must be a positive integer.\")\n        \n    steps = np.random.choice([-1, 1], size=elements)\n    walk = np.cumsum(steps)\n    descriptive_stats = pd.Series(walk).describe(percentiles=[.05, .25, .5, .75, .95]).to_dict()\n    \n    plt.figure(figsize=(10, 6))\n    plt.plot(walk)\n    plt.title('Random Walk')\n    return descriptive_stats, plt.gca()","inputs":{"source":"BigCodeBench","libraries":["doctest","matplotlib","numpy","pandas","unittest"],"code_prompt":"import numpy as np\nimport matplotlib.pyplot as plt\nimport pandas as pd\ndef task_func(elements, seed=0):\n","entry_point":"task_func"},"prompt":"Generate and draw a random sequence of \"elements\" number of steps. The steps are either -1 or 1, and the sequence is plotted as a random walk. Returns the descriptive statistics of the random walk and the plot of the random walk. The descriptive statistics include count, mean, standard deviation, minimum, 5th percentile, 25th percentile, median, 75th percentile, 95th percentile and maximum.\nThe function should raise the exception for: ValueError: If elements is not a positive integer.\nThe function should output with:\n    dict: A dictionary containing the descriptive statistics of the random walk.\n    matplotlib.axes.Axes: The Axes object with the plotted random walk.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport pandas as pd\ndef task_func(elements, seed=0):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-193","gold":"    data = {}\n    for col in range(columns):\n        data_type = choice(DATA_TYPES)\n        if data_type == str:\n            data['col' + str(col)] = [''.join(np.random.choice(list('abcdefghijklmnopqrstuvwxyz'), size=5)) for _ in\n                                      range(rows)]\n        elif data_type in [int, float]:\n            data['col' + str(col)] = np.random.choice([data_type(i) for i in range(10)], size=rows)\n        elif data_type == list:\n            data['col' + str(col)] = [list(np.random.choice(range(10), size=np.random.randint(1, 6))) for _ in\n                                      range(rows)]\n        elif data_type == tuple:\n            data['col' + str(col)] = [tuple(np.random.choice(range(10), size=np.random.randint(1, 6))) for _ in\n                                      range(rows)]\n        elif data_type == dict:\n            data['col' + str(col)] = [dict(zip(np.random.choice(range(10), size=np.random.randint(1, 6)),\n                                               np.random.choice(range(10), size=np.random.randint(1, 6)))) for _ in\n                                      range(rows)]\n        elif data_type == set:\n            data['col' + str(col)] = [set(np.random.choice(range(10), size=np.random.randint(1, 6))) for _ in\n                                      range(rows)]\n\n    df = pd.DataFrame(data)\n    return df","inputs":{"source":"BigCodeBench","libraries":["numpy","pandas","random","unittest"],"code_prompt":"import pandas as pd\nimport numpy as np\nfrom random import choice\n# Constants\nDATA_TYPES = [str, int, float, list, tuple, dict, set]\ndef task_func(rows, columns):\n","entry_point":"task_func"},"prompt":"Generates a DataFrame with a specified number of rows and columns, populated with randomly generated data. Each column's data type is randomly selected from a set of Python data types, including primitive and complex structures. DataFrame: A DataFrame in which each column's data type could be one of the following, with random content generated accordingly: - str: Random strings of 5 lowercase alphabetic characters. - int: Random integers from 0 to 9. - float: Random floats derived by converting integers from 0 to 9 into float. - list: Lists of random length (1 to 5) containing integers from 0 to 9. - tuple: Tuples of random length (1 to 5) containing integers from 0 to 9. - dict: Dictionaries with a random number (1 to 5) of key-value pairs, keys and values are integers from 0 to 9. - set: Sets of random size (1 to 5) containing unique integers from 0 to 9.\nThe function should output with:\n    pd.DataFrame: A DataFrame with the specified number of rows and columns named 'col0', 'col1', etc., containing randomly generated data.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport numpy as np\nfrom random import choice\n# Constants\nDATA_TYPES = [str, int, float, list, tuple, dict, set]\ndef task_func(rows, columns):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-1030","gold":"    LETTERS = list(string.ascii_lowercase)\n    combinations = list(itertools.product(LETTERS, repeat=3))\n\n    df = pd.DataFrame(combinations, columns=[\"Letter 1\", \"Letter 2\", \"Letter 3\"])\n\n    return df","inputs":{"source":"BigCodeBench","libraries":["itertools","pandas","string","unittest"],"code_prompt":"import itertools\nimport string\nimport pandas as pd\ndef task_func():\n","entry_point":"task_func"},"prompt":"Generate all possible combinations (with replacement) of three letters from the alphabet and save them in a pandas DataFrame.\nThe function should output with:\n    DataFrame: A pandas DataFrame with each row representing a unique combination of three letters.\nYou should write self-contained code starting with:\n```\nimport itertools\nimport string\nimport pandas as pd\ndef task_func():\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-221","gold":"\n    # Replace values using dictionary mapping\n    df = df.replace(dct)\n    \n    statistics = {}\n    try:\n        for feature in FEATURES:\n            # Calculate statistics\n            mean = np.mean(df[feature])\n            median = np.median(df[feature])\n            mode = stats.mode(df[feature])[0][0]\n            variance = np.var(df[feature])\n            \n            # Store statistics in dictionary\n            statistics[feature] = {'mean': mean, 'median': median, 'mode': mode, 'variance': variance}\n    except Exception as e:\n        return \"Invalid input\"        \n    return statistics","inputs":{"source":"BigCodeBench","libraries":["numpy","pandas","scipy","unittest"],"code_prompt":"import numpy as np\nfrom scipy import stats\n# Constants\nFEATURES = ['feature1', 'feature2', 'feature3', 'feature4', 'feature5']\ndef task_func(df, dct):\n","entry_point":"task_func"},"prompt":"This function calculates and returns the mean, median, mode, and variance for specified features in a DataFrame. It replaces certain values in the DataFrame based on a provided dictionary mapping before performing the calculations.\nNote that: The function would return \"Invalid input\" string if the input is invalid (e.g., does not contain the required 'feature1' key) or if there is an error in the calculation.\nThe function should output with:\n    dict: A dictionary containing statistics (mean, median, mode, variance) for each feature defined in the 'FEATURES' constant.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nfrom scipy import stats\n# Constants\nFEATURES = ['feature1', 'feature2', 'feature3', 'feature4', 'feature5']\ndef task_func(df, dct):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-64","gold":"    df = pd.DataFrame(data, columns=COLUMNS)\n    analyzed_df = df.groupby(COLUMNS[:-1])[COLUMNS[-1]].nunique().reset_index()\n    analyzed_df = analyzed_df.pivot(index=COLUMNS[0], columns=COLUMNS[1], values=COLUMNS[2])\n    ax = sns.heatmap(analyzed_df, annot=True)\n    plt.show()\n    return analyzed_df, ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","pandas","seaborn","unittest"],"code_prompt":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n# Constants\nCOLUMNS = ['col1', 'col2', 'col3']\ndef task_func(data):\n","entry_point":"task_func"},"prompt":"You are given a list of elements. Each element is a list with the same length as COLUMNS, representing one row a dataframe df to create. Visualize the distribution of different values in a column \"col3\" of a pandas DataFrame df, grouped by \"col1\" and \"col2,\" using a heatmap.\nThe function should output with:\n    tuple:\n    pandas.DataFrame: The DataFrame of the analyzed data.\n    plt.Axes: The heatmap visualization.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n# Constants\nCOLUMNS = ['col1', 'col2', 'col3']\ndef task_func(data):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-341","gold":"\n    if not isinstance(df, pd.DataFrame) or df.empty or col not in df.columns:\n        raise ValueError(\"The DataFrame is empty or the specified column does not exist.\")\n\n    fig, axes = plt.subplots(nrows=2, ncols=1)\n\n    # Plot histogram or count plot based on data type\n    if pd.api.types.is_numeric_dtype(df[col]):\n        axes[0].hist(df[col], bins=10, edgecolor='black', alpha=0.7)  # Using matplotlib's hist function for numerical data\n    else:\n        sns.countplot(x=df[col], ax=axes[0])\n\n    # Plot boxplot or strip plot based on data type\n    if pd.api.types.is_numeric_dtype(df[col]):\n        sns.boxplot(x=df[col], ax=axes[1])\n    else:\n        sns.stripplot(x=df[col], ax=axes[1], jitter=True)\n\n    return fig","inputs":{"source":"BigCodeBench","libraries":["matplotlib","pandas","seaborn","unittest"],"code_prompt":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\ndef task_func(df, col):\n","entry_point":"task_func"},"prompt":"This function takes a pandas DataFrame and a column name as input and generates two subplots in one matplotlib figure: the first subplot is a histogram (with a kernel density estimate for numerical data), and the second is a box plot, representing the distribution of the values in the specified column.\nThe function should raise the exception for: The input df must be DataFrame, not be empty, and must contain the specified column, if it is not, the function will raise ValueError.\nThe function should output with:\n    matplotlib.figure.Figure: A matplotlib figure object containing the histogram and box plot.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\ndef task_func(df, col):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-638","gold":"    scores = np.random.randint(0, 101, size=(num_teams, num_games))\n    teams = ['Team' + str(i) for i in range(1, num_teams + 1)]\n    games = ['Game' + str(i) for i in range(1, num_games + 1)]\n    df = pd.DataFrame(scores, index=teams, columns=games)\n    return df","inputs":{"source":"BigCodeBench","libraries":["numpy","pandas","unittest"],"code_prompt":"import numpy as np\nimport pandas as pd\ndef task_func(num_teams=5, num_games=100):\n","entry_point":"task_func"},"prompt":"Create a Pandas DataFrame that displays the random scores of different teams in multiple games. The function generates random scores for each game played by each team and populates them in a DataFrame with index=teams, columns=games.\nThe function should output with:\n    DataFrame: The generated DataFrame containing random scores for each team in each game.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport pandas as pd\ndef task_func(num_teams=5, num_games=100):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-225","gold":"    \n    if not isinstance(df, pd.DataFrame):\n        raise ValueError(\"The input df is not a DataFrame\")\n    \n    # Replace values using dictionary mapping\n    df_replaced = df.replace(dct)\n    \n    # Plot a histogram for each specified column\n    if plot_histograms and columns:\n        for column in columns:\n            if column in df_replaced:\n                df_replaced[column].plot.hist(bins=50)\n                plt.title(column)\n\n    return df_replaced","inputs":{"source":"BigCodeBench","libraries":["matplotlib","pandas","unittest"],"code_prompt":"import pandas as pd\nimport matplotlib.pyplot as plt\ndef task_func(df, dct, columns=None, plot_histograms=False):\n","entry_point":"task_func"},"prompt":"Replace values in a DataFrame with a dictionary mapping and optionally record histograms for specified columns.\nThe function should raise the exception for: The function will raise a ValueError is input df is not a DataFrame.\nThe function should output with:\n    DataFrame: The DataFrame with replaced values. The columns are in the format of 'col1', 'col2', etc.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport matplotlib.pyplot as plt\ndef task_func(df, dct, columns=None, plot_histograms=False):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-955","gold":"\n    if not text:\n        raise ValueError(\"text cannot be empty.\")\n\n    for word in mystrings:\n        text = re.sub(word, word.replace(\" \", \"_\"), text, flags=re.IGNORECASE)\n\n    word_counts = Counter(text.split())\n\n    words, frequencies = zip(*word_counts.items())\n    indices = np.arange(len(word_counts))\n\n    fig, ax = plt.subplots()\n    ax.bar(indices, frequencies)\n    ax.set_xticks(indices)\n    ax.set_xticklabels(words)\n\n    return ax","inputs":{"source":"BigCodeBench","libraries":["collections","matplotlib","numpy","re","unittest"],"code_prompt":"import numpy as np\nimport matplotlib.pyplot as plt\nimport re\nfrom collections import Counter\ndef task_func(mystrings, text):\n","entry_point":"task_func"},"prompt":"Replace spaces in given words with underscores, then plots the frequency of each unique word.\nNote that: Notes: All operations are case-insensitive. The frequency plot displays each unique word on the x-axis in the order they appear after modification with its corresponding frequency on the y-axis.\nThe function should raise the exception for: ValueError: If the input text is empty.\nThe function should output with:\n    matplotlib.axes.Axes: The Axes object of the plot.\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport re\nfrom collections import Counter\ndef task_func(mystrings, text):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-410","gold":"    excel_file = os.path.join(excel_directory, file_name)\n    if not os.path.exists(excel_file):\n        raise FileNotFoundError(f\"The file {excel_file} does not exist.\")\n\n    df = pd.read_excel(excel_file, engine='openpyxl')\n\n    if column_name not in df.columns:\n        raise ValueError(f\"Column {column_name} does not exist in the DataFrame.\")\n\n    try:\n        df[column_name] = pd.to_datetime(df[column_name])\n        start_date = datetime.strptime(start_date, '%Y-%m-%d')\n        end_date = datetime.strptime(end_date, '%Y-%m-%d')\n    except ValueError as e:\n        raise ValueError(\"Date format is incorrect. Please use 'yyyy-mm-dd' format.\") from e\n\n    filtered_df = df[(df[column_name] >= start_date) & (df[column_name] <= end_date)]\n\n    return filtered_df","inputs":{"source":"BigCodeBench","libraries":["datetime","numpy","os","pandas","unittest"],"code_prompt":"import os\nimport pandas as pd\nfrom datetime import datetime\ndef task_func(excel_directory: str, file_name: str, column_name: str, start_date: str, end_date: str) -> pd.DataFrame:\n","entry_point":"task_func"},"prompt":"Filters data in a specific date range from a column in an Excel file and returns a Pandas DataFrame of the filtered data.\nThe function should raise the exception for: FileNotFoundError: If the specified Excel file does not exist. ValueError: If start_date or end_date are in an incorrect format, or if column_name does not exist in the DataFrame.\nThe function should output with:\n    pd.DataFrame: A pandas DataFrame with the filtered data.\nYou should write self-contained code starting with:\n```\nimport os\nimport pandas as pd\nfrom datetime import datetime\ndef task_func(excel_directory: str, file_name: str, column_name: str, start_date: str, end_date: str) -> pd.DataFrame:\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-153","gold":"    le = LabelEncoder()\n    encoded = le.fit_transform(data)\n    df = pd.DataFrame({'Category': data, 'Encoded': encoded})\n\n    return df","inputs":{"source":"BigCodeBench","libraries":["pandas","sklearn","unittest"],"code_prompt":"import pandas as pd\nfrom sklearn.preprocessing import LabelEncoder\ndef task_func(data):\n","entry_point":"task_func"},"prompt":"Transforms categorical data into a numerical format suitable for machine learning algorithms using sklearn's LabelEncoder. This function generates a DataFrame that pairs original categorical values with their numerical encodings.\nThe function should output with:\n    DataFrame: A DataFrame with columns 'Category' and 'Encoded', where 'Category' is the original data and 'Encoded'\n    is the numerical representation.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nfrom sklearn.preprocessing import LabelEncoder\ndef task_func(data):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-818","gold":"    words = re.split(r'\\s+', text)\n    cleaned_words = [re.sub(f'[{PUNCTUATION}]', '', word).lower() for word in words]\n\n    return cleaned_words","inputs":{"source":"BigCodeBench","libraries":["re","string","unittest"],"code_prompt":"import re\nimport string\n# Constants\nPUNCTUATION = string.punctuation\ndef task_func(text):\n","entry_point":"task_func"},"prompt":"Divide a string into words, remove punctuation marks and convert them to lowercase letters.\nThe function should output with:\n    cleaned_words (list): A list of cleaned words.\nYou should write self-contained code starting with:\n```\nimport re\nimport string\n# Constants\nPUNCTUATION = string.punctuation\ndef task_func(text):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-40","gold":"    z_scores = zscore(data_matrix, axis=1)\n    feature_columns = [\"Feature \" + str(i + 1) for i in range(data_matrix.shape[1])]\n    df = pd.DataFrame(z_scores, columns=feature_columns)\n    df[\"Mean\"] = df.mean(axis=1)\n    correlation_matrix = df.corr()\n    ax = sns.heatmap(correlation_matrix, annot=True, fmt=\".2f\")\n    return df, ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","pandas","scipy","seaborn","unittest"],"code_prompt":"import pandas as pd\nimport seaborn as sns\nfrom scipy.stats import zscore\ndef task_func(data_matrix):\n","entry_point":"task_func"},"prompt":"Calculate the Z-values of a 2D data matrix, calculate the mean value of each row and then visualize the correlation matrix of the Z-values with a heatmap.\nThe function should output with:\n    tuple: A tuple containing:\n    pandas.DataFrame: A DataFrame with columns 'Feature 1', 'Feature 2', ..., 'Feature n' containing the Z-scores (per matrix row).\n    There is also an additional column 'Mean' the mean of z-score per row.\n    matplotlib.axes.Axes: The Axes object of the plotted heatmap.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport seaborn as sns\nfrom scipy.stats import zscore\ndef task_func(data_matrix):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-496","gold":"    np.random.seed(random_seed)\n\n    if days_in_past < 1:\n        raise ValueError(\"days_in_past must be in the past\")\n\n    dates = [datetime.now().date() - timedelta(days=i) for i in range(days_in_past)]\n    temperatures = np.random.randint(low=15, high=35, size=days_in_past)\n\n    fig, ax = plt.subplots()\n    ax.plot(dates, temperatures)\n    ax.set_xlabel(\"Date\")\n    ax.set_ylabel(\"Temperature (°C)\")\n    ax.set_title(\"Temperature Trend\")\n    return ax","inputs":{"source":"BigCodeBench","libraries":["datetime","matplotlib","numpy","unittest"],"code_prompt":"from datetime import datetime, timedelta\nimport numpy as np\nimport matplotlib.pyplot as plt\ndef task_func(days_in_past=7, random_seed=0):\n","entry_point":"task_func"},"prompt":"Draw a graph of temperature trends over the past week using randomly generated data. This function generates random integer temperatures in Celcius with a low of 15 and high of 35. To show temperature trend, it plots date on the x-axis and temperature on the y-axis.\nThe function should raise the exception for: ValueError: If days_in_past is less than 1.\nThe function should output with:\n    ax (matplotlib.axes._axes.Axes): Generated plot showing 'Temperature Trend'\n    with 'Date' on the a-xis and 'Temperature (°C)' on the y-axis.\nYou should write self-contained code starting with:\n```\nfrom datetime import datetime, timedelta\nimport numpy as np\nimport matplotlib.pyplot as plt\ndef task_func(days_in_past=7, random_seed=0):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-804","gold":"\n    if not isinstance(metrics, dict):\n        raise ValueError(\"Metrics must be a dictionary\")\n    if not isinstance(filename, str):\n        raise ValueError(\"Filename must be a string\")\n    \n    try:\n        with open(os.path.join(log_dir, filename), 'a') as f:\n            f.write(f'{datetime.now()}\\n')\n            for key, value in metrics.items():\n                f.write(f'{key}: {value}\\n')\n            f.write('\\n')\n        return True\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n        return False","inputs":{"source":"BigCodeBench","libraries":["datetime","os","unittest"],"code_prompt":"import os\nfrom datetime import datetime\n# Constants\nLOG_DIR = './logs'\ndef task_func(metrics, filename, log_dir=LOG_DIR):\n","entry_point":"task_func"},"prompt":"This function writes a dictionary of metrics to a specified log file, appending a timestamp to each entry. >>> metrics = {'precision': 0.75, 'recall': 0.80} >>> task_func(metrics, 'evaluation.log') An error occurred: [Errno 2] No such file or directory: './logs/evaluation.log' False\nThe function should output with:\n    bool: True if the metrics were successfully written to the file, False otherwise.\nYou should write self-contained code starting with:\n```\nimport os\nfrom datetime import datetime\n# Constants\nLOG_DIR = './logs'\ndef task_func(metrics, filename, log_dir=LOG_DIR):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-343","gold":"\n    # Ensure that the DataFrame is not empty and the specified column exists\n    if not isinstance(df, pd.DataFrame) or df.empty or col not in df.columns:\n        raise ValueError(\"The DataFrame is empty or the specified column does not exist.\")\n\n    # Compute the value counts for the specified column\n    value_counts = df[col].value_counts()\n\n    # Plot the pie chart with an optional title\n    ax = value_counts.plot(kind='pie', colors=COLORS[:len(value_counts)], autopct='%1.1f%%')\n    if title:\n        plt.title(title)\n\n    return ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","pandas","unittest"],"code_prompt":"import pandas as pd\nimport matplotlib.pyplot as plt\n# Constants for pie chart colors\nCOLORS = ['r', 'g', 'b', 'y', 'm']\ndef task_func(df, col, title=None):\n","entry_point":"task_func"},"prompt":"Draw a pie chart of the number of unique values in a given DataFrame column with an optional title.\nNote that: Each unique value in the column is represented by a slice in the pie chart with a unique color from a predefined set. The pie chart can have a title if specified.\nThe function should raise the exception for: The input df must be DataFrame, not be empty, and must contain the specified column, if it is not, the function will raise ValueError.\nThe function should output with:\n    Axes: A matplotlib axes object representing the pie chart.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport matplotlib.pyplot as plt\n# Constants for pie chart colors\nCOLORS = ['r', 'g', 'b', 'y', 'm']\ndef task_func(df, col, title=None):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-958","gold":"    if seed is not None:\n        random.seed(seed)\n\n    def scramble_word(match):\n        word = match.group(0)\n        if len(word) > 3:\n            middle = list(word[1:-1])\n            random.shuffle(middle)\n            return word[0] + \"\".join(middle) + word[-1]\n        else:\n            return word\n\n    pattern = r\"\\b\\w+\\b\"\n    scrambled_text = re.sub(pattern, scramble_word, text)\n\n    return scrambled_text","inputs":{"source":"BigCodeBench","libraries":["random","re","unittest"],"code_prompt":"import random\nimport re\ndef task_func(text, seed=None):\n","entry_point":"task_func"},"prompt":"Scramble the letters in each word of a given text, keeping the first and last letters of each word intact.\nNote that: Notes: Words are determined by regex word boundaries. The scrambling only affects words longer than three characters, leaving shorter words unchanged.\nThe function should output with:\n    str: The scrambled text.\nYou should write self-contained code starting with:\n```\nimport random\nimport re\ndef task_func(text, seed=None):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-119","gold":"    X = np.linspace(-10, 10, 400)\n    Y = X**2\n\n    plt.figure()\n    plt.plot(X, Y)\n    plt.title('y = x^2')\n    plt.xlabel('x')\n    plt.ylabel('y')\n    plt.grid(True)\n    plt.show()","inputs":{"source":"BigCodeBench","libraries":["matplotlib","numpy","unittest"],"code_prompt":"import numpy as np\nimport matplotlib.pyplot as plt\ndef task_func():\n","entry_point":"task_func"},"prompt":"Creates and displays a diagram of a parabola represented by the equation y = x^2. The function plots the parabola using matplotlib, sets the title as 'y = x^2', labels the axes as 'x' and 'y', and enables the grid. It uses a fixed range for x values from -10 to 10 with 400 points. This function is used for demonstrating basic plotting capabilities and visualizing quadratic functions. The function does not take any parameters and does not return any value.\nThe function should output with:\n    None\nYou should write self-contained code starting with:\n```\nimport numpy as np\nimport matplotlib.pyplot as plt\ndef task_func():\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-462","gold":"    if num_rows <= 0:\n        raise ValueError(\"num_rows must not be negative\")\n\n    random.seed(random_seed)\n\n    df = pd.DataFrame(\n        {\n            \"Category\": [\n                categories[random.randint(0, len(categories) - 1)]\n                for _ in range(num_rows)\n            ],\n            \"Value\": [random.randint(1, 100) for _ in range(num_rows)],\n        }\n    )\n\n    ax = (\n        df[\"Category\"]\n        .value_counts()\n        .plot(kind=\"bar\", title=\"Category Counts\", figsize=(10, 6))\n    )\n\n    return df, ax","inputs":{"source":"BigCodeBench","libraries":["matplotlib","pandas","random","unittest"],"code_prompt":"import pandas as pd\nimport random\ndef task_func(num_rows=100, categories=[\"a\", \"b\", \"c\", \"d\", \"e\"], random_seed=42):\n","entry_point":"task_func"},"prompt":"Create a Pandas DataFrame with specified number of rows. Each row contains a randomly selected category from the provided categories list and a random integer between 1 and 100. The function also generates a bar chart visualizing the counts of each category in the DataFrame and returns both the DataFrame and the bar chart.\nThe function should raise the exception for: ValueError: If num_rows is less than 1.\nThe function should output with:\n    pd.DataFrame: A pandas DataFrame with randomly generated category data.\n    matplotlib.pyplot.Axes: A bar chart visualizing the category counts, with the title 'Category Counts'.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport random\ndef task_func(num_rows=100, categories=[\"a\", \"b\", \"c\", \"d\", \"e\"], random_seed=42):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024},{"ref":"bigcodebench-951","gold":"    catalogue_data = []\n    random.seed(seed)\n    np.random.seed(seed)\n    for _ in range(n_products):\n        product_name = mystrings[randint(0, len(mystrings) - 1)].replace(' ', '_')\n        category = CATEGORIES[randint(0, len(CATEGORIES) - 1)]\n        price = round(np.random.normal(50, 10), 2)\n        catalogue_data.append([product_name, category, price])\n\n    catalogue_df = pd.DataFrame(catalogue_data, columns=['Product Name', 'Category', 'Price'])\n\n    return catalogue_df","inputs":{"source":"BigCodeBench","libraries":["numpy","pandas","random","unittest"],"code_prompt":"import pandas as pd\nimport numpy as np\nimport random\nfrom random import randint, seed\n# Constants\nCATEGORIES = ['Electronics', 'Clothing', 'Home & Kitchen', 'Books', 'Toys & Games']\ndef task_func(mystrings, n_products, seed=0):\n","entry_point":"task_func"},"prompt":"Create a product catalog DataFrame where each row represents a product with the following columns: - 'Product Name': The name of the product with spaces replaced by underscores. - 'Category': The category to which the product belongs. - 'Price': The price of the product, generated randomly based on a normal distribution with a mean of 50 and a standard deviation of 10. Constants: - CATEGORIES: A list of categories used to randomly assign a category to each product.\nThe function should output with:\n    pd.DataFrame: A pandas DataFrame containing the product catalog information.\nYou should write self-contained code starting with:\n```\nimport pandas as pd\nimport numpy as np\nimport random\nfrom random import randint, seed\n# Constants\nCATEGORIES = ['Electronics', 'Clothing', 'Home & Kitchen', 'Books', 'Toys & Games']\ndef task_func(mystrings, n_products, seed=0):\n```\n\nReturn only the complete Python function, including its imports. Do not include explanation, tests, or example usage.","partition":"train","max_output_tokens":1024}],"reference_model":"","reference":[]}