Skip to content

Commit

Permalink
Merge pull request #1101 from ranaroussi/hotfix/tz-dst-ambiguous
Browse files Browse the repository at this point in the history
Fix tz-localize when DST-ambiguous
  • Loading branch information
ValueRaider committed Oct 21, 2022
2 parents b27cc0c + f1ad8f0 commit 75c823a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion yfinance/base.py
Expand Up @@ -313,7 +313,9 @@ def history(self, period="1mo", interval="1d",
elif params["interval"] == "1h":
pass
else:
df.index = _pd.to_datetime(df.index.date).tz_localize(tz_exchange)
# If a midnight is during DST transition hour when clocks roll back,
# meaning clock hits midnight twice, then use the 2nd (ambiguous=True)
df.index = _pd.to_datetime(df.index.date).tz_localize(tz_exchange, ambiguous=True)
df.index.name = "Date"

# duplicates and missing rows cleanup
Expand Down

0 comments on commit 75c823a

Please sign in to comment.