Get month name in Arquero table

I’m having trouble creating a column containing the month name in an Arquero table. It seems as if the Date.toLocaleDateString("default", { month: "long" }) method can’t be called when using derive to create a new column.

Similarly, it seems as if I can’t reference a separate array with month names:

// Tried to use a separate array, but can't seem to reference it properly
month_name = protests
  .derive({ month_num: d => op.month(d.Date) })
  .derive({ month_name: d => monthNames[d.month_num] })
  .select("Date", "month_num")

More details in this notebook. Thanks!

I think you need to use table.params() (see

You might be interested by the conversation we add with @bmschmidt :


Amazing, thanks! FWIW, I added the solution to the notebook:

  .params({ monthNames: monthNames })
  .derive({ month: (d, $) => $.monthNames[op.month(d.Date)] })
  .select("Date", "month")

I would like to filter an Arquero table from an observable input selector.
But I am stuck, the following is a snapshot of a reproducible example I created:
Screen Shot 2021-02-07 at 12.24.19

Any suggestions is super welcome
Thanks in advance!

Maybe it’s the same problem as in Get month name in Arquero table - #2 by severo


@severo Thanks, that was exactly what was needed!
Super grateful for your feedback!

1 Like

FYI: More than likely, multiple date/time formatting will be done on Arquero tables (eg: date, day of week, year, hours, minutes, etc.) In that event, using d3’s date formatting (or a library-independent formatting) through Arquero’s extended functions is a viable option:

The following pattern is library-independent, will provide multi-formatting flexibility and perform well:

const dateFormatting = new Intl.DateTimeFormat("en-US",{month: "long"});

aq.addFunction("getMonth", x => dateFormatting.format(x));

return protests
          .derive({ month: d => op.getMonth(d.Date)})
          .select("Date", "month")