@@ -2,15 +2,18 @@ from datetime import datetime, date, timedelta
22import operator
33import numpy as np
44
5+ cdef extern from " datetime_helper.h" :
6+ double total_seconds(object )
7+
58from pandas import compat
6- from pandas.core import common as com
7- from pandas.core.base import PandasObject
89
910from pandas.tseries import frequencies
1011from pandas.tseries.frequencies import get_freq_code as _gfc
1112from pandas.tseries import offsets
1213from pandas.tseries.tools import parse_time_string
1314
15+ cimport lib
16+ import lib
1417from pandas import tslib
1518from tslib import Timedelta, Timestamp
1619
@@ -26,7 +29,7 @@ def _period_field_accessor(name, alias):
2629 return property(f)
2730
2831
29- class Period (PandasObject ):
32+ class Period (object ):
3033 """
3134 Represents an period of time
3235
@@ -74,7 +77,7 @@ class Period(PandasObject):
7477 raise ValueError ((" Only value or ordinal but not both should be "
7578 " given but not both" ))
7679 elif ordinal is not None :
77- if not com .is_integer(ordinal):
80+ if not lib .is_integer(ordinal):
7881 raise ValueError (" Ordinal must be an integer" )
7982 if freq is None :
8083 raise ValueError (' Must supply freq for ordinal value' )
@@ -96,14 +99,14 @@ class Period(PandasObject):
9699 converted = other.asfreq(freq)
97100 self .ordinal = converted.ordinal
98101
99- elif com.is_null_datelike_scalar (value) or value in tslib._nat_strings:
102+ elif lib.is_null_datetimelike (value) or value in tslib._nat_strings:
100103 self .ordinal = tslib.iNaT
101104 if freq is None :
102105 raise ValueError (" If value is NaT, freq cannot be None "
103106 " because it cannot be inferred" )
104107
105- elif isinstance (value, compat.string_types) or com .is_integer(value):
106- if com .is_integer(value):
108+ elif isinstance (value, compat.string_types) or lib .is_integer(value):
109+ if lib .is_integer(value):
107110 value = str (value)
108111 value = value.upper()
109112
@@ -184,7 +187,7 @@ class Period(PandasObject):
184187 if isinstance (other, (timedelta, np.timedelta64,
185188 offsets.Tick, offsets.DateOffset, Timedelta)):
186189 return self ._add_delta(other)
187- elif com .is_integer(other):
190+ elif lib .is_integer(other):
188191 if self .ordinal == tslib.iNaT:
189192 ordinal = self .ordinal
190193 else :
@@ -198,7 +201,7 @@ class Period(PandasObject):
198201 offsets.Tick, offsets.DateOffset, Timedelta)):
199202 neg_other = - other
200203 return self + neg_other
201- elif com .is_integer(other):
204+ elif lib .is_integer(other):
202205 if self .ordinal == tslib.iNaT:
203206 ordinal = self .ordinal
204207 else :
@@ -320,15 +323,15 @@ class Period(PandasObject):
320323 def now (cls , freq = None ):
321324 return Period(datetime.now(), freq = freq)
322325
326+ # HACK IT UP AND YOU BETTER FIX IT SOON
327+ def __str__ (self ):
328+ return self .__unicode__ ()
329+
323330 def __repr__ (self ):
324331 base, mult = _gfc(self .freq)
325332 formatted = tslib.period_format(self .ordinal, base)
326333 freqstr = frequencies._reverse_period_code_map[base]
327334
328- if not compat.PY3:
329- encoding = com.get_option(" display.encoding" )
330- formatted = formatted.encode(encoding)
331-
332335 return " Period('%s ', '%s ')" % (formatted, freqstr)
333336
334337 def __unicode__ (self ):
0 commit comments