I have a Dataset of only 1 column to start with, and I want to StringJoin every element there. Got the error message

StringJoin::string: String expected at position 1 in StringJoin[Dataset [<<33>>]].

Here is code to reproduce:

a = {1, 2, 3}
b = Dataset[ToString /@ a]
c = StringJoin[b]

Tried Normal[StringJoin[b]] & Normal[b], neither worked.

Thanks in advance.

  • $\begingroup$ StringJoin[(# & /@ Normal@b)] is this what you're looking for? Edit: Commented before seeing WReach's answer. It's a really nice way of doing this! :) $\endgroup$ – Vahagn Tumanyan May 4 '17 at 16:57
  • $\begingroup$ This solution works, thanks! $\endgroup$ – user1470393 May 4 '17 at 17:14

StringJoin is not one of the functions that support a dataset argument. We can, however, use StringJoin as a query operator:


(* "123" *)

We can see the functions which do accept a dataset argument by inspecting the output of:


PrintDefinitions screenshot

The list is quite a bit longer than will fit in a screenshot.

| improve this answer | |


a = {1, 2, 3};
b = Dataset[ToString /@ a];

b[StringJoin, All] (*Method 1, apply StringJoin to the contents of all columns/a specific column*)
StringJoin @@ b (*Method 2, replace Dataset head with StringJoin*)


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.