Skip to content

Commit 9556e90

Browse files
only convert to pytz if installed
1 parent 9e89af8 commit 9556e90

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pandas/tests/io/test_parquet.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ def test_timestamp_nanoseconds(self, pa):
973973
df = pd.DataFrame({"a": pd.date_range("2017-01-01", freq="1ns", periods=10)})
974974
check_round_trip(df, pa, write_kwargs={"version": ver})
975975

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):
977977
pytest.importorskip("pyarrow", "11.0.0")
978978

979979
idx = 5 * [timezone_aware_date_list]
@@ -995,12 +995,15 @@ def test_timezone_aware_index(self, request, pa, timezone_aware_date_list):
995995
if timezone_aware_date_list.tzinfo != datetime.timezone.utc:
996996
# pyarrow returns pytz.FixedOffset while pandas constructs datetime.timezone
997997
# 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)
10041007
check_round_trip(df, pa, check_dtype=False, expected=expected)
10051008

10061009
def test_filter_row_groups(self, pa):

0 commit comments

Comments
 (0)