Beispiel #1
0
    def get_period_from_ordinal(date_ordinal, freq=None):
        if not freq in constants.CACHE_FREQUENCY:
            return str(pandas.Period(ordinal=date_ordinal, freq=freq))

        key = "o-to-p-%s.%s" % (date_ordinal, freq)
        value = cache.get(key)
        if value:
            return value

        value = str(pandas.Period(ordinal=date_ordinal, freq=freq))
        cache.set(key, value, timeout=300)
        return value
Beispiel #2
0
 def get_period_from_ordinal(date_ordinal, freq=None):
     if not freq in constants.CACHE_FREQUENCY:
         return str(pandas.Period(ordinal=date_ordinal, freq=freq))
 
     key = "o-to-p-%s.%s" % (date_ordinal, freq)
     value = cache.get(key)
     if value:
         return value
     
     value = str(pandas.Period(ordinal=date_ordinal, freq=freq))
     cache.set(key, value, timeout=300)
     return value
Beispiel #3
0
    def get_ordinal_from_period(date_str, freq=None):
        if not freq in constants.CACHE_FREQUENCY:
            return pandas.Period(date_str, freq=freq).ordinal

        key = "p-to-o-%s.%s" % (date_str, freq)
        value = cache.get(key)
        if value:
            return value

        value = pandas.Period(date_str, freq=freq).ordinal
        cache.set(key, value, timeout=300)
        return value
Beispiel #4
0
 def get_ordinal_from_period(date_str, freq=None):
     if not freq in constants.CACHE_FREQUENCY:
         return pandas.Period(date_str, freq=freq).ordinal
     
     key = "p-to-o-%s.%s" % (date_str, freq)
     value = cache.get(key)
     if value:
         return value
     
     value = pandas.Period(date_str, freq=freq).ordinal
     cache.set(key, value, timeout=300)
     return value