Why do pandas and python differ in how they convert a datetime to America/Boise?

73 views Asked by At

Here's an example:

import pandas as pd

from datetime import datetime, timezone
from zoneinfo import ZoneInfo

string = '2038-04-01 09:00:00.000000'

dt = datetime.fromisoformat(string)
dt = dt.replace(tzinfo=timezone.utc)
tz = ZoneInfo('America/Boise')
converted_dt = dt.astimezone(tz)
print(converted_dt)
print(pd.Timestamp(string).tz_localize('UTC').tz_convert('America/Boise'))

This prints:

2038-04-01 03:00:00-06:00
2038-04-01 02:00:00-07:00

Why do they have different offsets?

0

There are 0 answers