🏠 back to Observable

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 https://uwdata.github.io/arquero/api/table#params).

You might be interested by the conversation we add with @bmschmidt : https://observablehq.com/@bmschmidt/exploring-changing-us-college-majors-with-arquero#comment-858c591ca4faecc0


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

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