I am wondering if there is a straightforward way to add a new column to a dataset if the column needs to be computed from the key values rather than other columns. Here is a simple example.
dataset=<|101-><|"Column1"->"a"|>,
102-><|"Column1"->"b"|>,
201-><|"Column1"->"c"|>|>//Dataset
I want to add Column2 = f[Key], where Key is {101,102,201}
and, say,
f[x_]:=FromDigits@Take[IntegerDigits[x], 1]
So far it seems I have to go a long way around: extract the key column, apply the function to it, then somehow merge the result with the dataset, which itself needs to be converted to an association and then back. Is there maybe a better way?
P.S. I have a unique row key due to an earlier reshape operation, which I could only achieve using GroupBy, which automatically created a key. It feels to me the functionality with unique row keys is somewhat raw. On one hand, they are supported by some dataset related functions like GroupBy and are shown nicely in the output. On the other hand, joining two dataset on external key from one and a unique key from the other is probably going to be a hassle.