<commit_before># -*- coding: utf-8 -*-
"""
Created on Tue Nov 18 13:40:53 2014
HisRecord must be seen as the representation of one historical trend to be analysed by pandas

@author: CTremblay
"""
import re,datetime
import numpy as np
import pyhaystack.util.tools as tools
import pandas as pd
from pandas import Series
import datetime
from hszinc import zoneinfo, Quantity

class HisRecord():
    """
    This class is a single record
    - hisId is the haystack Id of the trend
    - data is created as DataFrame to be used directly in Pandas
    """
    def __init__(self, session, hisId, dateTimeRange='today'):
        """
        GET data from server and fill this object with historical info
        """
        # Grab logger child from session
        self._log = session._log.getChild('hisRecord.%s' % hisId)

        # Grab metadata
        self._meta      = session.getHistMeta(hisId)
        self.tz_name    = self._meta['tz']
        self.tz         = zoneinfo.timezone(self.tz_name)

        # Is dateTimeRange a tuple object?
        if isinstance(dateTimeRange, tuple):
            (dtStart, dtEnd) = dateTimeRange
            # Convert these to native time
            def _to_native(dt):
                self._log.debug('Converting %s to native time', dt)
                if isinstance(dt, datetime.datetime):
                    if dt.tzinfo is None:
                        # Assume time is already local
                        self._log.debug('Localise to timezone %s', self.tz_name)
                        dt = self.tz.localize(dt)<commit_msg>history.HisRecord: Clean up unused imports<commit_after># -*- coding: utf-8 -*-
"""
Created on Tue Nov 18 13:40:53 2014
HisRecord must be seen as the representation of one historical trend to be analysed by pandas

@author: CTremblay
"""
import datetime
import numpy as np
import pandas as pd
from pandas import Series
from hszinc import zoneinfo, Quantity

class HisRecord():
    """
    This class is a single record
    - hisId is the haystack Id of the trend
    - data is created as DataFrame to be used directly in Pandas
    """
    def __init__(self, session, hisId, dateTimeRange='today'):
        """
        GET data from server and fill this object with historical info
        """
        # Grab logger child from session
        self._log = session._log.getChild('hisRecord.%s' % hisId)

        # Grab metadata
        self._meta      = session.getHistMeta(hisId)
        self.tz_name    = self._meta['tz']
        self.tz         = zoneinfo.timezone(self.tz_name)

        # Is dateTimeRange a tuple object?
        if isinstance(dateTimeRange, tuple):
            (dtStart, dtEnd) = dateTimeRange
            # Convert these to native time
            def _to_native(dt):
                self._log.debug('Converting %s to native time', dt)
                if isinstance(dt, datetime.datetime):
                    if dt.tzinfo is None:
                        # Assume time is already local
                        self._log.debug('Localise to timezone %s', self.tz_name)
                        dt = self.tz.localize(dt)
{'fraction_non_alphanumeric': 0.08150773195876289, 'fraction_numerical': 0.008376288659793814, 'mean_word_length': 2.130040322580645, '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': '6415309', 'n_tokens_mistral': 868, 'n_tokens_neox': 813, 'n_words': 307}