Skip to main content
edited body
Source Link
Coolwater
  • 20.5k
  • 3
  • 39
  • 66
lst = With[{c = CharacterRange["a", "z"], r = RandomReal[{-2, 2}, 20]},
  Flatten[{RandomChoice[c, {#, 2}], RandomChoice[r, {#, 2}]}, {{2}, {1, 3}}] &[150000]];

As a workaround you can use the 3rd argument of GroupbyGroupBy which correspond to the functionality of Map:

a = lst // GroupBy[(#[[2]] &) -> (Drop[#, {2}] &)] // Map[GroupBy[First -> Rest]];
b = GroupBy[lst[[All, {2, 1, 3, 4}]], #, GroupBy[#]] &[First -> Rest];
a === b
True
lst = With[{c = CharacterRange["a", "z"], r = RandomReal[{-2, 2}, 20]},
  Flatten[{RandomChoice[c, {#, 2}], RandomChoice[r, {#, 2}]}, {{2}, {1, 3}}] &[150000]];

As a workaround you can use the 3rd argument of Groupby which correspond to the functionality of Map:

a = lst // GroupBy[(#[[2]] &) -> (Drop[#, {2}] &)] // Map[GroupBy[First -> Rest]];
b = GroupBy[lst[[All, {2, 1, 3, 4}]], #, GroupBy[#]] &[First -> Rest];
a === b
True
lst = With[{c = CharacterRange["a", "z"], r = RandomReal[{-2, 2}, 20]},
  Flatten[{RandomChoice[c, {#, 2}], RandomChoice[r, {#, 2}]}, {{2}, {1, 3}}] &[150000]];

As a workaround you can use the 3rd argument of GroupBy which correspond to the functionality of Map:

a = lst // GroupBy[(#[[2]] &) -> (Drop[#, {2}] &)] // Map[GroupBy[First -> Rest]];
b = GroupBy[lst[[All, {2, 1, 3, 4}]], #, GroupBy[#]] &[First -> Rest];
a === b
True
Source Link
Coolwater
  • 20.5k
  • 3
  • 39
  • 66

lst = With[{c = CharacterRange["a", "z"], r = RandomReal[{-2, 2}, 20]},
  Flatten[{RandomChoice[c, {#, 2}], RandomChoice[r, {#, 2}]}, {{2}, {1, 3}}] &[150000]];

As a workaround you can use the 3rd argument of Groupby which correspond to the functionality of Map:

a = lst // GroupBy[(#[[2]] &) -> (Drop[#, {2}] &)] // Map[GroupBy[First -> Rest]];
b = GroupBy[lst[[All, {2, 1, 3, 4}]], #, GroupBy[#]] &[First -> Rest];
a === b
True