DATA SCIENCESOUTH

Time to learn about datetimes in Python.

from datetime import datetime

#  create an ISO timestamp of current UTC time
dt = datetime.utcnow().isoformat()

#  string + format code -> object
dt = datetime.strptime('%Y-%m-%d', '2022-02-01')

#  object + format code -> string
dt.strftime("%Y-%m-%dT%H:%M:%S")

#  today's date in YYYY-MM-DD format
dt = datetime.utcnow().strftime('%Y-%m-%d')

Chapter 1: What is a datetime?

Date, time, datetime, today, utcnow, timedelta, isoformat, format codes, strftime, strptime.

Chapter 2: Timezones & Daylight Saving

Timezones, why they are hard, advice, timezone naive & aware, pytz, localization, conversion, standard timezones, day-light saving.

Chapter 3: Datetimes in Pandas

pd.Timestamp, pd.to_datetime, day versus month first, creating date ranges, working with datetime columns, timezones, resampling, groupby.