<commit_before>from __future__ import absolute_import

from numbers import Number

import copy

from plotly import exceptions, optional_imports
import plotly.colors as clrs
from plotly.figure_factory import utils
import plotly.graph_objects as go

pd = optional_imports.get_module("pandas")

REQUIRED_GANTT_KEYS = ["Task", "Start", "Finish"]


def _get_corner_points(x0, y0, x1, y1):
    """
    Returns the corner points of a scatter rectangle

    :param x0: x-start
    :param y0: y-lower
    :param x1: x-end
    :param y1: y-upper
    :return: ([x], [y]), tuple of lists containing the x and y values
    """

    return ([x0, x1, x1, x0], [y0, y0, y1, y1])


def validate_gantt(df):
    """
    Validates the inputted dataframe or list
    """
    if pd and isinstance(df, pd.core.frame.DataFrame):
        # validate that df has all the required keys
        for key in REQUIRED_GANTT_KEYS:
            if key not in df:
                raise exceptions.PlotlyError(
                    "The columns in your dataframe must include the "
                    "following keys: {0}".format(", ".join(REQUIRED_GANTT_KEYS))
                )

        num_of_rows = len(df.index)
        chart = []
        for index in range(num_of_rows):
            task_dict = {}
            for key in df:
                task_dict[key] = df.ix[index][key]
            chart.append(task_dict)

        return chart

    # validate if df is a list
    if not isinstance(df, list):
        raise exceptions.PlotlyError(
            "You must input either a dataframe " "or a list of dictionaries."
        )
<commit_msg>:alien: upgrade code so it no longer uses deprecated pandas method ix (#2011)<commit_after>from __future__ import absolute_import

from numbers import Number

import copy

from plotly import exceptions, optional_imports
import plotly.colors as clrs
from plotly.figure_factory import utils
import plotly.graph_objects as go

pd = optional_imports.get_module("pandas")

REQUIRED_GANTT_KEYS = ["Task", "Start", "Finish"]


def _get_corner_points(x0, y0, x1, y1):
    """
    Returns the corner points of a scatter rectangle

    :param x0: x-start
    :param y0: y-lower
    :param x1: x-end
    :param y1: y-upper
    :return: ([x], [y]), tuple of lists containing the x and y values
    """

    return ([x0, x1, x1, x0], [y0, y0, y1, y1])


def validate_gantt(df):
    """
    Validates the inputted dataframe or list
    """
    if pd and isinstance(df, pd.core.frame.DataFrame):
        # validate that df has all the required keys
        for key in REQUIRED_GANTT_KEYS:
            if key not in df:
                raise exceptions.PlotlyError(
                    "The columns in your dataframe must include the "
                    "following keys: {0}".format(", ".join(REQUIRED_GANTT_KEYS))
                )

        num_of_rows = len(df.index)
        chart = []
        for index in range(num_of_rows):
            task_dict = {}
            for key in df:
                task_dict[key] = df.iloc[index][key]
            chart.append(task_dict)

        return chart

    # validate if df is a list
    if not isinstance(df, list):
        raise exceptions.PlotlyError(
            "You must input either a dataframe " "or a list of dictionaries."
        )

{'fraction_non_alphanumeric': 0.09121415497254423, 'fraction_numerical': 0.011592434411226357, 'mean_word_length': 2.328934010152284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5008057', 'n_tokens_mistral': 1049, 'n_tokens_neox': 1000, 'n_words': 338}