You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
131 lines
5.4 KiB
131 lines
5.4 KiB
pandas/compat/__init__.py | 14 ++++++++++++++
|
|
pandas/tests/test_series.py | 3 ++-
|
|
pandas/tseries/tests/test_daterange.py | 2 +-
|
|
pandas/tseries/tests/test_period.py | 8 ++++----
|
|
pandas/tseries/tests/test_timeseries.py | 6 +++---
|
|
pandas/tslib.pyx | 6 +++++-
|
|
6 files changed, 29 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/pandas/compat/__init__.py b/pandas/compat/__init__.py
|
|
index 6be0fac..2a27362 100644
|
|
--- a/pandas/compat/__init__.py
|
|
+++ b/pandas/compat/__init__.py
|
|
@@ -26,6 +26,7 @@ Python 2.6 compatibility:
|
|
|
|
Other items:
|
|
* OrderedDefaultDict
|
|
+* platform checker
|
|
"""
|
|
# pylint disable=W0611
|
|
import functools
|
|
@@ -754,3 +755,16 @@ class OrderedDefaultdict(OrderedDict):
|
|
def __reduce__(self): # optional, for pickle support
|
|
args = self.default_factory if self.default_factory else tuple()
|
|
return type(self), args, None, None, list(self.items())
|
|
+
|
|
+
|
|
+# https://github.com/pydata/pandas/pull/9123
|
|
+def is_platform_windows():
|
|
+ return sys.platform == 'win32' or sys.platform == 'cygwin'
|
|
+
|
|
+
|
|
+def is_platform_linux():
|
|
+ return sys.platform == 'linux2'
|
|
+
|
|
+
|
|
+def is_platform_mac():
|
|
+ return sys.platform == 'darwin'
|
|
diff --git a/pandas/tests/test_series.py b/pandas/tests/test_series.py
|
|
index 22f8aee..925cfa8 100644
|
|
--- a/pandas/tests/test_series.py
|
|
+++ b/pandas/tests/test_series.py
|
|
@@ -5398,7 +5398,8 @@ class TestSeries(tm.TestCase, CheckNameIntegration):
|
|
def test_getitem_setitem_datetime_tz_dateutil(self):
|
|
tm._skip_if_no_dateutil();
|
|
from dateutil.tz import tzutc
|
|
- from dateutil.zoneinfo import gettz
|
|
+ from pandas.tslib import _dateutil_gettz as gettz
|
|
+
|
|
tz = lambda x: tzutc() if x == 'UTC' else gettz(x) # handle special case for utc in dateutil
|
|
|
|
from pandas import date_range
|
|
diff --git a/pandas/tseries/tests/test_daterange.py b/pandas/tseries/tests/test_daterange.py
|
|
index 841d81c..69b1d84 100644
|
|
--- a/pandas/tseries/tests/test_daterange.py
|
|
+++ b/pandas/tseries/tests/test_daterange.py
|
|
@@ -441,7 +441,7 @@ class TestDateRange(tm.TestCase):
|
|
def test_month_range_union_tz_dateutil(self):
|
|
_skip_if_windows_python_3()
|
|
tm._skip_if_no_dateutil()
|
|
- from dateutil.zoneinfo import gettz as timezone
|
|
+ from pandas.tslib import _dateutil_gettz as timezone
|
|
tz = timezone('US/Eastern')
|
|
|
|
early_start = datetime(2011, 1, 1)
|
|
diff --git a/pandas/tseries/tests/test_period.py b/pandas/tseries/tests/test_period.py
|
|
index 70c706f..0218af6 100644
|
|
--- a/pandas/tseries/tests/test_period.py
|
|
+++ b/pandas/tseries/tests/test_period.py
|
|
@@ -101,15 +101,15 @@ class TestPeriodProperties(tm.TestCase):
|
|
pytz.timezone('Europe/Brussels').normalize(p).tzinfo)
|
|
|
|
def test_timestamp_tz_arg_dateutil(self):
|
|
- import dateutil
|
|
+ from pandas.tslib import _dateutil_gettz as gettz
|
|
from pandas.tslib import maybe_get_tz
|
|
p = Period('1/1/2005', freq='M').to_timestamp(tz=maybe_get_tz('dateutil/Europe/Brussels'))
|
|
- self.assertEqual(p.tz, dateutil.zoneinfo.gettz('Europe/Brussels'))
|
|
+ self.assertEqual(p.tz, gettz('Europe/Brussels'))
|
|
|
|
def test_timestamp_tz_arg_dateutil_from_string(self):
|
|
- import dateutil
|
|
+ from pandas.tslib import _dateutil_gettz as gettz
|
|
p = Period('1/1/2005', freq='M').to_timestamp(tz='dateutil/Europe/Brussels')
|
|
- self.assertEqual(p.tz, dateutil.zoneinfo.gettz('Europe/Brussels'))
|
|
+ self.assertEqual(p.tz, gettz('Europe/Brussels'))
|
|
|
|
def test_timestamp_nat_tz(self):
|
|
t = Period('NaT', freq='M').to_timestamp()
|
|
diff --git a/pandas/tseries/tests/test_timeseries.py b/pandas/tseries/tests/test_timeseries.py
|
|
index 0c4961d..6c20b02 100644
|
|
--- a/pandas/tseries/tests/test_timeseries.py
|
|
+++ b/pandas/tseries/tests/test_timeseries.py
|
|
@@ -417,9 +417,9 @@ class TestTimeSeries(tm.TestCase):
|
|
def test_timestamp_to_datetime_explicit_dateutil(self):
|
|
_skip_if_windows_python_3()
|
|
tm._skip_if_no_dateutil()
|
|
- import dateutil
|
|
+ from pandas.tslib import _dateutil_gettz as gettz
|
|
rng = date_range('20090415', '20090519',
|
|
- tz=dateutil.zoneinfo.gettz('US/Eastern'))
|
|
+ tz=gettz('US/Eastern'))
|
|
|
|
stamp = rng[0]
|
|
dtval = stamp.to_pydatetime()
|
|
@@ -1807,7 +1807,7 @@ class TestTimeSeries(tm.TestCase):
|
|
def test_append_concat_tz_dateutil(self):
|
|
# GH 2938
|
|
tm._skip_if_no_dateutil()
|
|
- from dateutil.zoneinfo import gettz as timezone
|
|
+ from pandas.tslib import _dateutil_gettz as timezone
|
|
|
|
rng = date_range('5/8/2012 1:45', periods=10, freq='5T',
|
|
tz='dateutil/US/Eastern')
|
|
diff --git a/pandas/tslib.pyx b/pandas/tslib.pyx
|
|
index 66f14bf..a0d4ee0 100644
|
|
--- a/pandas/tslib.pyx
|
|
+++ b/pandas/tslib.pyx
|
|
@@ -41,7 +41,11 @@ from datetime import time as datetime_time
|
|
# dateutil compat
|
|
from dateutil.tz import (tzoffset, tzlocal as _dateutil_tzlocal, tzfile as _dateutil_tzfile,
|
|
tzutc as _dateutil_tzutc)
|
|
-from dateutil.zoneinfo import gettz as _dateutil_gettz
|
|
+from pandas.compat import is_platform_windows
|
|
+if is_platform_windows():
|
|
+ from dateutil.tz import gettz as _dateutil_gettz
|
|
+else:
|
|
+ from dateutil.zoneinfo import gettz as _dateutil_gettz
|
|
|
|
from pytz.tzinfo import BaseTzInfo as _pytz_BaseTzInfo
|
|
from pandas.compat import parse_date, string_types, PY3, iteritems
|