Created
June 11, 2021 13:41
-
-
Save HumanRupert/9f9f53f9188e052386f55e0f5fc01a4c 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
def convert_date_cols(df: pd.DataFrame) -> pd.DataFrame: | |
"""Given a dataframe, adds UTC timezone to all columns that have date in their names.""" | |
for col in df.columns: | |
if("date" in col.lower()): | |
df[col] = pd.to_datetime(df[col]).dt.tz_localize("UTC") | |
return df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment