@@ -2067,6 +2067,10 @@ def test_append_with_timezones_dateutil(self):
2067
2067
except ImportError :
2068
2068
raise nose .SkipTest
2069
2069
2070
+ # use maybe_get_tz instead of dateutil.tz.gettz to handle the windows filename issues.
2071
+ from pandas .tslib import maybe_get_tz
2072
+ gettz = lambda x : maybe_get_tz ('dateutil/' + x )
2073
+
2070
2074
def compare (a , b ):
2071
2075
tm .assert_frame_equal (a , b )
2072
2076
@@ -2082,7 +2086,7 @@ def compare(a, b):
2082
2086
with ensure_clean_store (self .path ) as store :
2083
2087
2084
2088
_maybe_remove (store , 'df_tz' )
2085
- df = DataFrame (dict (A = [ Timestamp ('20130102 2:00:00' , tz = dateutil . tz . gettz ('US/Eastern' )) + timedelta (hours = 1 ) * i for i in range (5 ) ]))
2089
+ df = DataFrame (dict (A = [ Timestamp ('20130102 2:00:00' , tz = gettz ('US/Eastern' )) + timedelta (hours = 1 ) * i for i in range (5 ) ]))
2086
2090
store .append ('df_tz' , df , data_columns = ['A' ])
2087
2091
result = store ['df_tz' ]
2088
2092
compare (result , df )
@@ -2093,14 +2097,14 @@ def compare(a, b):
2093
2097
2094
2098
_maybe_remove (store , 'df_tz' )
2095
2099
# ensure we include dates in DST and STD time here.
2096
- df = DataFrame (dict (A = Timestamp ('20130102' , tz = dateutil . tz . gettz ('US/Eastern' )), B = Timestamp ('20130603' , tz = dateutil . tz . gettz ('US/Eastern' ))), index = range (5 ))
2100
+ df = DataFrame (dict (A = Timestamp ('20130102' , tz = gettz ('US/Eastern' )), B = Timestamp ('20130603' , tz = gettz ('US/Eastern' ))), index = range (5 ))
2097
2101
store .append ('df_tz' , df )
2098
2102
result = store ['df_tz' ]
2099
2103
compare (result , df )
2100
2104
assert_frame_equal (result , df )
2101
2105
2102
2106
_maybe_remove (store , 'df_tz' )
2103
- df = DataFrame (dict (A = Timestamp ('20130102' , tz = dateutil . tz . gettz ('US/Eastern' )), B = Timestamp ('20130102' , tz = dateutil . tz . gettz ('EET' ))), index = range (5 ))
2107
+ df = DataFrame (dict (A = Timestamp ('20130102' , tz = gettz ('US/Eastern' )), B = Timestamp ('20130102' , tz = gettz ('EET' ))), index = range (5 ))
2104
2108
self .assertRaises (TypeError , store .append , 'df_tz' , df )
2105
2109
2106
2110
# this is ok
@@ -2111,14 +2115,14 @@ def compare(a, b):
2111
2115
assert_frame_equal (result , df )
2112
2116
2113
2117
# can't append with diff timezone
2114
- df = DataFrame (dict (A = Timestamp ('20130102' , tz = dateutil . tz . gettz ('US/Eastern' )), B = Timestamp ('20130102' , tz = dateutil . tz . gettz ('CET' ))), index = range (5 ))
2118
+ df = DataFrame (dict (A = Timestamp ('20130102' , tz = gettz ('US/Eastern' )), B = Timestamp ('20130102' , tz = gettz ('CET' ))), index = range (5 ))
2115
2119
self .assertRaises (ValueError , store .append , 'df_tz' , df )
2116
2120
2117
2121
# as index
2118
2122
with ensure_clean_store (self .path ) as store :
2119
2123
2120
2124
# GH 4098 example
2121
- df = DataFrame (dict (A = Series (lrange (3 ), index = date_range ('2000-1-1' , periods = 3 , freq = 'H' , tz = dateutil . tz . gettz ('US/Eastern' )))))
2125
+ df = DataFrame (dict (A = Series (lrange (3 ), index = date_range ('2000-1-1' , periods = 3 , freq = 'H' , tz = gettz ('US/Eastern' )))))
2122
2126
2123
2127
_maybe_remove (store , 'df' )
2124
2128
store .put ('df' , df )
0 commit comments