|
|
@@ -1,5 +1,5 @@ |
|
|
# pylint: disable-msg=E1101,W0612
|
|
|
-from datetime import datetime, time, timedelta, tzinfo, date
|
|
|
+from datetime import datetime, timedelta, tzinfo, date
|
|
|
import sys
|
|
|
import os
|
|
|
import unittest
|
|
|
@@ -8,10 +8,9 @@ |
|
|
import numpy as np
|
|
|
import pytz
|
|
|
|
|
|
-from pandas import (Index, Series, TimeSeries, DataFrame, isnull,
|
|
|
- date_range, Timestamp)
|
|
|
+from pandas import (Index, Series, DataFrame, isnull, Timestamp)
|
|
|
|
|
|
-from pandas import DatetimeIndex, Int64Index, to_datetime, NaT
|
|
|
+from pandas import DatetimeIndex, to_datetime, NaT
|
|
|
from pandas import tslib
|
|
|
|
|
|
import pandas.core.datetools as datetools
|
|
|
@@ -20,17 +19,10 @@ |
|
|
import pandas.tseries.tools as tools
|
|
|
from pytz import NonExistentTimeError
|
|
|
|
|
|
-from pandas.util.testing import assert_series_equal, assert_almost_equal, assertRaisesRegexp
|
|
|
import pandas.util.testing as tm
|
|
|
|
|
|
-import pandas.lib as lib
|
|
|
-import pandas.core.datetools as dt
|
|
|
-from numpy.random import rand
|
|
|
from pandas.util.testing import assert_frame_equal
|
|
|
-import pandas.compat as compat
|
|
|
-from pandas.compat import range, lrange, zip, cPickle as pickle
|
|
|
-from pandas.core.datetools import BDay
|
|
|
-import pandas.core.common as com
|
|
|
+from pandas.compat import lrange, zip
|
|
|
|
|
|
from pandas import _np_version_under1p7
|
|
|
|
|
|
@@ -544,13 +536,13 @@ def test_localized_at_time_between_time(self): |
|
|
|
|
|
result = ts_local.at_time(time(10, 0))
|
|
|
expected = ts.at_time(time(10, 0)).tz_localize(self.tzstr('US/Eastern'))
|
|
|
- assert_series_equal(result, expected)
|
|
|
+ tm.assert_series_equal(result, expected)
|
|
|
self.assertTrue(self.cmptz(result.index.tz, self.tz('US/Eastern')))
|
|
|
|
|
|
t1, t2 = time(10, 0), time(11, 0)
|
|
|
result = ts_local.between_time(t1, t2)
|
|
|
expected = ts.between_time(t1, t2).tz_localize(self.tzstr('US/Eastern'))
|
|
|
- assert_series_equal(result, expected)
|
|
|
+ tm.assert_series_equal(result, expected)
|
|
|
self.assertTrue(self.cmptz(result.index.tz, self.tz('US/Eastern')))
|
|
|
|
|
|
def test_string_index_alias_tz_aware(self):
|
|
|
@@ -631,7 +623,7 @@ def test_frame_no_datetime64_dtype(self): |
|
|
'datetimes_with_tz' : datetimes_with_tz })
|
|
|
result = df.get_dtype_counts()
|
|
|
expected = Series({ 'datetime64[ns]' : 3, 'object' : 1 })
|
|
|
- assert_series_equal(result, expected)
|
|
|
+ tm.assert_series_equal(result, expected)
|
|
|
|
|
|
def test_hongkong_tz_convert(self):
|
|
|
# #1673
|
|
|
@@ -863,7 +855,7 @@ def test_series_frame_tz_localize(self): |
|
|
# Can't localize if already tz-aware
|
|
|
rng = date_range('1/1/2011', periods=100, freq='H', tz='utc')
|
|
|
ts = Series(1, index=rng)
|
|
|
- assertRaisesRegexp(TypeError, 'Already tz-aware', ts.tz_localize, 'US/Eastern')
|
|
|
+ tm.assertRaisesRegexp(TypeError, 'Already tz-aware', ts.tz_localize, 'US/Eastern')
|
|
|
|
|
|
def test_series_frame_tz_convert(self):
|
|
|
rng = date_range('1/1/2011', periods=200, freq='D',
|
|
|
@@ -887,7 +879,7 @@ def test_series_frame_tz_convert(self): |
|
|
# can't convert tz-naive
|
|
|
rng = date_range('1/1/2011', periods=200, freq='D')
|
|
|
ts = Series(1, index=rng)
|
|
|
- assertRaisesRegexp(TypeError, "Cannot convert tz-naive", ts.tz_convert, 'US/Eastern')
|
|
|
+ tm.assertRaisesRegexp(TypeError, "Cannot convert tz-naive", ts.tz_convert, 'US/Eastern')
|
|
|
|
|
|
def test_join_utc_convert(self):
|
|
|
rng = date_range('1/1/2011', periods=100, freq='H', tz='utc')
|
|
|
@@ -1033,7 +1025,7 @@ def test_arith_utc_convert(self): |
|
|
expected = uts1 + uts2
|
|
|
|
|
|
self.assertEqual(result.index.tz, pytz.UTC)
|
|
|
- assert_series_equal(result, expected)
|
|
|
+ tm.assert_series_equal(result, expected)
|
|
|
|
|
|
def test_intersection(self):
|
|
|
rng = date_range('1/1/2011', periods=100, freq='H', tz='utc')
|
|
|
|