<commit_before>from goerr import err
from ..utils import _write_file
from chartflo.serializers import convert_dataset


class DataTable():
    """
    A class to handle data tables
    """

    def create(self, slug, dataset, dashboard=None):
        df = convert_dataset(dataset)
        if df is None:
            if df is None:
                err.new(
                    self.new, "No dataframe set: please provide one in parameter")
                err.throw()
            else:
                df = df
        html = self._html(slug, df)
        _write_file(slug, html, "datatable", dashboard)

    def _html(self, slug, df):
        """
        Renders a html datatable from a dataframe
        """
        cols = df.columns.values
        html = '<table id="' + slug + '" class="table table-bordered table-striped">'
        html += '<thead><tr>'
        for col in cols:
            html += '<th>' + col + '</th>'
        html += '</tr></thead><tbody>'
        for _, row in df.iterrows():<commit_msg>Fix datatables for api change<commit_after>from goerr import err
from ..utils import _write_file
from ..apps import cf


class DataTable():
    """
    A class to handle data tables
    """

    def create(self, slug, dataset, dashboard=None):
        df = cf.convert_dataset(dataset)
        if df is None:
            if df is None:
                err.new(
                    self.new, "No dataframe set: please provide one in parameter")
                err.throw()
            else:
                df = df
        html = self._html(slug, df)
        _write_file(slug, html, "datatable", dashboard)

    def _html(self, slug, df):
        """
        Renders a html datatable from a dataframe
        """
        cols = df.columns.values
        html = '<table id="' + slug + '" class="table table-bordered table-striped">'
        html += '<thead><tr>'
        for col in cols:
            html += '<th>' + col + '</th>'
        html += '</tr></thead><tbody>'
        for _, row in df.iterrows():
{'fraction_non_alphanumeric': 0.1221449851042701, 'fraction_numerical': 0.0, 'mean_word_length': 1.8025034770514603, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '4712694', 'n_tokens_mistral': 589, 'n_tokens_neox': 559, 'n_words': 187}