Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Like an operator form of GroupBy, but where one also specifies a reducer function to be applied
ResourceFunction["MapReduceOperator"][f→g,h] creates an operator that will group its argument using function f, map g onto each top level element of its argument and then map the reducer function h over each grouping. |
Group the data by the first element in each list, then get the last element of each list, and then compute the Mean of each grouping:
In[1]:= |
Out[1]= |
Group a list of integers according to their parity, compute their square roots, and display the results as column vectors:
In[2]:= |
Out[2]= |
Use MapReduceOperator with slot functions to create an operator that works on lists of associations (optionally wrapped in Dataset) and then apply it to the Titanic dataset:
In[3]:= |
Out[3]= |
The same query as above, but with the reducer function Counts run in parallel on the Normal form of the dataset:
In[4]:= |
Out[4]= |
"Parallelize" can take on the value True or False. If it is set to anything else, it is treated as if it were False. "Parallelize" will produce error messages if the data is wrapped in Dataset:
In[5]:= |
Out[5]= |
Applying Normal to the dataset will fix this problem:
In[6]:= |
Out[6]= |
Get histograms of the number of dates between the diagnosis of AIDS and death of the patient broken down by Australian state:
In[7]:= |
Out[7]= |
Group the planets according to the number of moons and compute for each grouping the median volume of the planets (assuming they are spherical):
In[8]:= |
Out[8]= |
Compute the fraction surviving (True) and dying on the Titanic as a function of their cabin class and sex and do so in parallel using a composition of the resource function Proportions and a built-in function:
In[9]:= |
Out[9]= |
Compute the Mean age of passengers on the Titanic broken down by class and deleting data for which age is Missing:
In[10]:= |
Out[10]= |
To omit the transformation of the grouped data, use Identity as follows:
In[11]:= |
Out[11]= |
This work is licensed under a Creative Commons Attribution 4.0 International License