Created
August 15, 2019 17:53
-
-
Save erickpeirson/327e74fe77e3d5cffbcf479c30eb45f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from datetime import datetime | |
from pytz import UTC, timezone | |
ET = timezone('US/Eastern') | |
s = pd.Series([datetime.now(UTC)]) # This is the same as a column in your dataframe. | |
def convert_datetime(dt: datetime) -> datetime: | |
"""Convert a localized datetime to Eastern time.""" | |
return dt.astimezone(ET) | |
s.apply(convert_datetime) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment