Nodes/ComfyUI-Data-Analysis/Pandas To Datetime
ComfyUI Node

Pandas To Datetime

Turn messy date strings into real datetime columns

By HowToSD·Created 2 years ago·Updated about a year ago· 23
Pandas To Datetime
  • dataframe
  • DATAFRAME
column_names
date_format

Every real dataset has at least one column of dates that arrived as text, and text dates are useless until you parse them. Pandas To Datetime converts one or more string columns in a DataFrame into proper datetime columns. It's the parse half of the pack's date story - Pandas Strftime formats them back out later.

Why bother? Until a column is real datetime dtype, you can't sort by it meaningfully, subtract dates, or extract year/month/day. Once parsed, that column becomes the backbone of time-series work: sort by date, group by month, feed a time-series plot. In a baseball-style workflow you'd load a CSV with a date column of strings, run this node, and suddenly the timeline is usable.

How it works

You name the target columns (comma-separated) and it applies pd.to_datetime(col, format=date_format) to each. The format field defaults to empty; for standard ISO-ish dates pandas can usually figure things out, but for anything unusual - "July 15, 2024", European day-first order, or timestamps with timezones - spell out the format explicitly using Python's strptime codes (%Y-%m-%d, %B %d, %Y, and so on). The author links the Python datetime docs from the node docstring, and there's a useful footnote there: if a column contains only a time, the date defaults to 1900-01-01.

Inputs and outputs

  • dataframe (DATAFRAME) - the frame holding the string columns.
  • column_names (STRING, default empty) - comma-separated exact column names, e.g. date,reported_at.
  • date_format (STRING, default empty) - the strptime format, if you need to force one.

Output: a single DATAFRAME with the named columns converted to datetime dtype.

Installing this pack

This node ships in ComfyUI-Data-Analysis by Hide Inada (HowToSD). CPU-only, no GPU, no model downloads - but the pack needs its Python stack, which stock ComfyUI lacks: pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml.

ComfyUI Manager: Manager → Custom Node Manager → search "Data analysis" → install ComfyUI-Data-Analysis → restart ComfyUI and refresh the browser. Manager installs the deps.

Git clone:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
mv ComfyUI-Data-Analysis data-analysis   # example workflows depend on this folder name
pip install -r data-analysis/requirements.txt

Restart ComfyUI after installing.

Troubleshooting

  • "time data ... does not match format" error. Your format string doesn't match the actual values. The most common culprit: your dates are day-first (15/07/2024) and you told it month-first (%d/%m/%Y vs %m/%d/%Y). Fix the format string.
  • Mixed-format column. If some rows are 2024-07-15 and others are 15/07/2024, no single format string works. Normalize the column text upstream first.
  • How do I know it worked? Check the output with Pandas Show DataFrame - a datetime column prints without quotes and sorts correctly. Or run Pandas Strftime on it to confirm it's genuinely datetime.
CategoryData Analysis

Inputs (3)

NameTypeDefaultDescription
dataframeDATAFRAME
column_namesSTRING
date_formatSTRING

Outputs (1)

NameTypeDescription
DATAFRAMEDATAFRAME