Split ISO date strings into (year, month, day) integer tuples by parsing each string at the '-' delimiter. With pandas, pd.to_datetime converts a string column to datetime64, enabling date arithmetic and .dt accessors.

By hand

Loop over date_strs, split each on '-', and convert the three parts to ints. Building (year, month, day) tuples keeps the components together in result and makes the parsed structure visible in each trace step.

naive.py
Replay: real traced execution (multi-file project)
date_strs = ['2024-01-15', '2024-03-22', '2024-07-04', '2024-11-11']
result = []
for s in date_strs:
    parts = s.split('-')
    result.append((int(parts[0]), int(parts[1]), int(parts[2])))
print('RESULT:', result)
  1. date_strs ← ['2024-01-15', '2024-03-22', '2024-07-04', '2024-11-11']

    1date_strs = ['2024-01-15', '2024-03-22', '2024-07-04', '2024-11-11']2result = []
    values this step['2024-01-15', '2024-03-22', '2024-07-04', '2024-11-11']date_strs
  2. result ← []

    1date_strs = ['2024-01-15', '2024-03-22', '2024-07-04', '2024-11-11']2result = []3for s in date_strs:
    values this step[]result
  3. s ← '2024-01-15'

    2result = []3for s in date_strs:4    parts = s.split('-')
    values this step'2024-01-15's
  4. parts ← ['2024', '01', '15']

    3for s in date_strs:4    parts = s.split('-')5    result.append((int(parts[0]), int(parts[1]), int(parts[2])))
    values this step['2024', '01', '15']parts
  5. result ← [(2024, 1, 15)]

    4    parts = s.split('-')5    result.append((int(parts[0]), int(parts[1]), int(parts[2])))6print('RESULT:', result)
    values this step[] [(2024, 1, 15)]result
  6. s ← '2024-03-22'

    2result = []3for s in date_strs:4    parts = s.split('-')
    values this step'2024-01-15' '2024-03-22's
  7. parts ← ['2024', '03', '22']

    3for s in date_strs:4    parts = s.split('-')5    result.append((int(parts[0]), int(parts[1]), int(parts[2])))
    values this step['2024', '01', '15'] ['2024', '03', '22']parts
  8. result ← [(2024, 1, 15), (2024, 3, 22)]

    4    parts = s.split('-')5    result.append((int(parts[0]), int(parts[1]), int(parts[2])))6print('RESULT:', result)
    values this step[(2024, 1, 15)] [(2024, 1, 15), (2024, 3, 22)]result
  9. s ← '2024-07-04'

    2result = []3for s in date_strs:4    parts = s.split('-')
    values this step'2024-03-22' '2024-07-04's
  10. parts ← ['2024', '07', '04']

    3for s in date_strs:4    parts = s.split('-')5    result.append((int(parts[0]), int(parts[1]), int(parts[2])))
    values this step['2024', '03', '22'] ['2024', '07', '04']parts
  11. result ← [(2024, 1, 15), (2024, 3, 22), (2024, 7, 4)]

    4    parts = s.split('-')5    result.append((int(parts[0]), int(parts[1]), int(parts[2])))6print('RESULT:', result)
    values this step[(2024, 1, 15), (2024, 3, 22)] [(2024, 1, 15), (2024, 3, 22), (2024, 7, 4)]result
  12. s ← '2024-11-11'

    2result = []3for s in date_strs:4    parts = s.split('-')
    values this step'2024-07-04' '2024-11-11's
  13. parts ← ['2024', '11', '11']

    3for s in date_strs:4    parts = s.split('-')5    result.append((int(parts[0]), int(parts[1]), int(parts[2])))
    values this step['2024', '07', '04'] ['2024', '11', '11']parts
  14. result ← [(2024, 1, 15), (2024, 3, 22), (2024, 7, 4), (2024, 11, 11)]

    4    parts = s.split('-')5    result.append((int(parts[0]), int(parts[1]), int(parts[2])))6print('RESULT:', result)
    values this step[(2024, 1, 15), (2024, 3, 22), (2024, 7, 4)] [(2024, 1, 15), (2024, 3, 22), (2024, 7, 4), (2024, 11, 11)]result
  15. for s in date_strs:

    2result = []3for s in date_strs:4    parts = s.split('-')
  16. stdout ← RESULT: [(2024, 1, 15), (2024, 3, 22), (2024, 7, 4), (2024, 11, 11)]

    5    result.append((int(parts[0]), int(parts[1]), int(parts[2])))6print('RESULT:', result)
    values this stepRESULT: [(2024, 1, 15), (2024, 3, 22), (2024, 7, 4), (2024, 11, 11)]stdout

With pandas

pd.to_datetime(df['date']) parses the string column into a datetime64[ns] Series in one call. The snapshot shows the ISO-formatted values via .dt.strftime and the dtype; result extracts integer components for deterministic comparison with the naive half.

library.py
import pandas as pd
from dalib.display import set_display
set_display()

date_strs = ['2024-01-15', '2024-03-22', '2024-07-04', '2024-11-11']
df = pd.DataFrame({'date': date_strs})
s = pd.to_datetime(df['date'])
result = list(zip(s.dt.year.tolist(), s.dt.month.tolist(), s.dt.day.tolist()))
print('index:', s.index.tolist())
print('values:', s.dt.strftime('%Y-%m-%d').tolist())
print('dtype:', s.dtype)
print('RESULT:', result)
index: [0, 1, 2, 3]
values: ['2024-01-15', '2024-03-22', '2024-07-04', '2024-11-11']
dtype: datetime64[ns]
RESULT: [(2024, 1, 15), (2024, 3, 22), (2024, 7, 4), (2024, 11, 11)]

Implementation notes

  • pd.to_datetime infers common date formats automatically. For ambiguous or non-standard strings, pass format='%Y-%m-%d' to be explicit and faster.
  • Once parsed to datetime64, the column gains .dt accessors for components and arithmetic — see extract-date-parts.
  • Date equality: both halves extract plain Python int tuples — avoiding any mismatch between stdlib datetime.date objects and pandas Timestamp.
  • Cross-reference: extract-date-parts (this chapter) for .dt accessor usage after parsing.