<commit_before>from collections import MutableMapping
from .lazy_import import LazyImport
from .utilities import table_output, to_datetime

class DataFrame(MutableMapping):
    '''A group of TimeSeries.'''

    def __init__(self, *args, **kwargs):
        self.groups = {}
        self.update(dict(*args, **kwargs))

    @property
    def timestamps(self):
        '''Get all timestamps from all series in the group.'''
        timestamps = set()
        for series in self.groups.itervalues():
            timestamps |= set(series.timestamps)
        return sorted(list(timestamps))

    def trend(self, **kwargs):
        '''Calculate a trend for all series in the group. See the
        `TimeSeries.trend()` method for more information.'''
        return DataFrame({ name: series.trend(**kwargs) \
            for name, series in self.groups.iteritems() })

    def forecast(self, horizon, **kwargs):
        '''Forecast all time series in the group. See the
        `TimeSeries.forecast()` method for more information.'''
        return DataFrame({ name: series.forecast(horizon, **kwargs) \
            for name, series in self.groups.iteritems() })

    def plot(self, overlay=True, **labels): # pragma: no cover
        '''Plot all time series in the group.'''
        pylab = LazyImport.pylab()
        colours = list('rgbymc')
        colours_len = len(colours)
        colours_pos = 0
        plots = len(self.groups)
        for name, series in self.groups.iteritems():
            colour = colours[colours_pos % colours_len]
            colours_pos += 1
            if not overlay:
                pylab.subplot(plots, 1, colours_pos)
            kwargs = {}
            if name in labels:
                name = labels[name]
            if name is not None:
                kwargs['label'] = name
            pylab.plot(series.dates, series.y, '%s-' % colour, **kwargs)
            if name is not None:
                pylab.legend()
        pylab.show()

    def rename(self, **kwargs):<commit_msg>Fix bug from previous commit<commit_after>from collections import MutableMapping
from .lazy_import import LazyImport
from .utilities import table_output, to_datetime

class DataFrame(MutableMapping):
    '''A group of TimeSeries.'''

    def __init__(self, *args, **kwargs):
        self.groups = {}
        self.update(dict(*args, **kwargs))

    @property
    def timestamps(self):
        '''Get all timestamps from all series in the group.'''
        timestamps = set()
        for series in self.groups.itervalues():
            timestamps |= set(series.timestamps)
        return sorted(list(timestamps))

    def trend(self, **kwargs):
        '''Calculate a trend for all series in the group. See the
        `TimeSeries.trend()` method for more information.'''
        return DataFrame({ name: series.trend(**kwargs) \
            for name, series in self.groups.iteritems() })

    def forecast(self, horizon, **kwargs):
        '''Forecast all time series in the group. See the
        `TimeSeries.forecast()` method for more information.'''
        return DataFrame({ name: series.forecast(horizon, **kwargs) \
            for name, series in self.groups.iteritems() })

    def plot(self, overlay=True, **labels): # pragma: no cover
        '''Plot all time series in the group.'''
        pylab = LazyImport.pylab()
        colours = list('rgbymc')
        colours_len = len(colours)
        colours_pos = 0
        plots = len(self.groups)
        for name, series in self.groups.iteritems():
            colour = colours[colours_pos % colours_len]
            colours_pos += 1
            if not overlay:
                pylab.subplot(plots, 1, colours_pos)
            kwargs = {}
            if name in labels:
                name = labels[name]
            if name is not None:
                kwargs['label'] = name
            pylab.plot(series.dates, series.values, '%s-' % colour, **kwargs)
            if name is not None:
                pylab.legend()
        pylab.show()

    def rename(self, **kwargs):
{'fraction_non_alphanumeric': 0.11374876360039565, 'fraction_numerical': 0.001483679525222552, 'mean_word_length': 2.2282521947326415, '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': '3274873', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1116, 'n_words': 349}