@@ -973,7 +973,7 @@ def test_timestamp_nanoseconds(self, pa):
973
973
df = pd .DataFrame ({"a" : pd .date_range ("2017-01-01" , freq = "1ns" , periods = 10 )})
974
974
check_round_trip (df , pa , write_kwargs = {"version" : ver })
975
975
976
- def test_timezone_aware_index (self , request , pa , timezone_aware_date_list ):
976
+ def test_timezone_aware_index (self , pa , timezone_aware_date_list ):
977
977
pytest .importorskip ("pyarrow" , "11.0.0" )
978
978
979
979
idx = 5 * [timezone_aware_date_list ]
@@ -995,12 +995,15 @@ def test_timezone_aware_index(self, request, pa, timezone_aware_date_list):
995
995
if timezone_aware_date_list .tzinfo != datetime .timezone .utc :
996
996
# pyarrow returns pytz.FixedOffset while pandas constructs datetime.timezone
997
997
# https://github.com/pandas-dev/pandas/issues/37286
998
- import pytz
999
-
1000
- offset = df .index .tz .utcoffset (timezone_aware_date_list )
1001
- tz = pytz .FixedOffset (offset .total_seconds () / 60 )
1002
- expected .index = expected .index .tz_convert (tz )
1003
- expected ["index_as_col" ] = expected ["index_as_col" ].dt .tz_convert (tz )
998
+ try :
999
+ import pytz
1000
+ except ImportError :
1001
+ pass
1002
+ else :
1003
+ offset = df .index .tz .utcoffset (timezone_aware_date_list )
1004
+ tz = pytz .FixedOffset (offset .total_seconds () / 60 )
1005
+ expected .index = expected .index .tz_convert (tz )
1006
+ expected ["index_as_col" ] = expected ["index_as_col" ].dt .tz_convert (tz )
1004
1007
check_round_trip (df , pa , check_dtype = False , expected = expected )
1005
1008
1006
1009
def test_filter_row_groups (self , pa ):
0 commit comments