Last active
January 16, 2025 06:55
-
-
Save scubamut/83292ee3034aaff1bb2b0c29937210f7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| # Option 1: Make naive datetimes timezone-aware | |
| # Add timezone to naive datetime | |
| naive_dt = pd.to_datetime('2024-01-01') | |
| aware_dt = naive_dt.tz_localize('UTC') # or any timezone like 'US/Eastern' | |
| # Option 2: Remove timezone from aware datetime | |
| aware_dt = pd.to_datetime('2024-01-01', utc=True) | |
| naive_dt = aware_dt.tz_localize(None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment