Ciaren

Extract date parts

Extract date parts — extractDateParts

Add columns for parts of a date/datetime column.

Use cases

  • Add year/month columns to group sales by period.
  • Pull weekday or hour for time-of-week analysis.

What it does

Adds one new column per requested part, named <column>_<part>. All original columns are preserved.

Before
event_idoccurred_atvalue
12024-01-0510
22024-02-1821
32024-03-0117
3 rows · 3 cols
Extract date parts (column=occurred_at, parts=[year, month])
After
event_idoccurred_atvalueoccurred_at_yearnewoccurred_at_monthnew
12024-01-051020241
22024-02-182120242
32024-03-011720243
3 rows · 5 cols

Configuration

Config keyTypeRequiredDescription
columnstringYesDate/datetime column
partsstring[]YesAny of year, month, day, weekday, hour

Each part becomes a new column named <column>_<part> (e.g. ordered_at_year).

Generated Python code

_dt = pd.to_datetime(df_1['ordered_at'])
df_2 = df_1.assign(ordered_at_year=_dt.dt.year, ordered_at_month=_dt.dt.month)

Tips & common mistakes

  • weekday is Monday=0 … Sunday=6 (consistent across pandas and polars exports — verified by the parity tests).
  • If the source is text, Parse dates or Change typesdatetime first; this node also parses on the fly but an explicit parse is clearer.

See also