@@ -993,16 +993,9 @@ def test_timestamp_nanoseconds(self, pa):
993
993
df = pd .DataFrame ({"a" : pd .date_range ("2017-01-01" , freq = "1ns" , periods = 10 )})
994
994
check_round_trip (df , pa , write_kwargs = {"version" : ver })
995
995
996
- def test_timezone_aware_index (self , request , pa , timezone_aware_date_list ):
996
+ def test_timezone_aware_index (self , pa , timezone_aware_date_list ):
997
997
pytest .importorskip ("pyarrow" , "11.0.0" )
998
998
999
- if timezone_aware_date_list .tzinfo != datetime .timezone .utc :
1000
- request .applymarker (
1001
- pytest .mark .xfail (
1002
- reason = "temporary skip this test until it is properly resolved: "
1003
- "https://github.com/pandas-dev/pandas/issues/37286"
1004
- )
1005
- )
1006
999
idx = 5 * [timezone_aware_date_list ]
1007
1000
df = pd .DataFrame (index = idx , data = {"index_as_col" : idx })
1008
1001
@@ -1015,7 +1008,23 @@ def test_timezone_aware_index(self, request, pa, timezone_aware_date_list):
1015
1008
# they both implement datetime.tzinfo
1016
1009
# they both wrap datetime.timedelta()
1017
1010
# this use-case sets the resolution to 1 minute
1018
- check_round_trip (df , pa , check_dtype = False )
1011
+
1012
+ expected = df [:]
1013
+ if pa_version_under11p0 :
1014
+ expected .index = expected .index .as_unit ("ns" )
1015
+ if timezone_aware_date_list .tzinfo != datetime .timezone .utc :
1016
+ # pyarrow returns pytz.FixedOffset while pandas constructs datetime.timezone
1017
+ # https://github.com/pandas-dev/pandas/issues/37286
1018
+ try :
1019
+ import pytz
1020
+ except ImportError :
1021
+ pass
1022
+ else :
1023
+ offset = df .index .tz .utcoffset (timezone_aware_date_list )
1024
+ tz = pytz .FixedOffset (offset .total_seconds () / 60 )
1025
+ expected .index = expected .index .tz_convert (tz )
1026
+ expected ["index_as_col" ] = expected ["index_as_col" ].dt .tz_convert (tz )
1027
+ check_round_trip (df , pa , check_dtype = False , expected = expected )
1019
1028
1020
1029
def test_filter_row_groups (self , pa ):
1021
1030
# https://github.com/pandas-dev/pandas/issues/26551
0 commit comments