0PricingLogin
Data Science Academy · Lesson

Parse Strings Into Datetimes

to_datetime and format handling.

Dates Hide as Text

When you load a CSV, dates usually arrive as plain strings. They look right but pandas treats them as text, so date math just won't work yet. 📅

Enter to_datetime

The fix is one function: pd.to_datetime. It scans your text and turns each value into a real timestamp pandas can compute with.

import pandas as pd
ts = pd.to_datetime("2024-03-15")
print(ts)

All lessons in this course

  1. Parse Strings Into Datetimes
  2. Extract Year, Month, and Weekday
  3. Resample to Daily or Monthly
  4. Time Zones and Date Ranges
← Back to Data Science Academy