OverviewΒΆ

Click on a nut name for more details.

Decorators & Wrappers : convert plain Python functions to nuts

>>> GreaterThan2 = nut_filter(lambda x: x > 2)
>>> [1, 2, 3, 4] >> GreaterThan2() >> Collect()
[3, 4]
  • nut_filter : wrapper to create nut filters.

  • nut_filterfalse : wrapper to create nut filters with inversed logic.

  • nut_function : wrapper for nut functions that operate on elements.

  • nut_processor : wrapper for nut processors that operate on iterables.

  • nut_sink : wrapper for nut sinks that aggregate data flows.

  • nut_source : wrapper for nut sources that generate data.

Printing : printing of data

>>> [1, 2.3, 'text'] >> PrintType() >> Consume()
<int> 1
<float> 2.3
<str> text

Sources : generate iterable data

>>> Range(5) >> Collect()
[0, 1, 2, 3, 4]
  • Empty : empty source that does not generate anything.

  • Enumerate : generate infinite number of increasing integers.

  • Product : generate Cartesian product of iterables.

  • Range : generate range of integer numbers.

  • ReadCSV : read elements from file in CSV (or TSV) format.

  • Repeat : repeats a value n times or infinitely.

Sinks : aggregate iterable data

>>> [1, 2, 3] >> Count()
3
  • ArgMax : return index of largest element.

  • ArgMin : return index of smallest element.

  • Collect : collect elements in a container, e.g. list, set, dict.

  • Consume : consumes input and returns nothing.

  • Count : count number of elements.

  • CountValues : return dictionary with counts of the different values.

  • Head : collect first n elements in a container, e.g. list, set, dict.

  • Join : join elements in a string.

  • Max : return largest element.

  • Mean : compute mean value of elements.

  • MeanStd : compute mean and standard deviation.

  • Min : return smallest element.

  • Next : get next element.

  • Nth : get n-th element.

  • Reduce : reduce inputs with a given function.

  • Sort : return sorted list of elements.

  • Sum : return sum of elements.

  • Tail : collect last n elements in a container, e.g. list, set, dict.

  • Unzip : reverses Zip() and unzips tuple elements.

  • WriteCSV : write elements to file in CSV (or TSV) format.

Functions : operate on individual elements and return elements

>>> [1, 2, 3] >> Square() >> Collect()
[1, 4, 9]
  • Counter : counts elements in an external variable - use for debugging only.

  • Format : format element as a string.

  • Get : extract slice from (indexable) element.

  • GetCols : extract columns from (indexable) element.

  • Identity : returns the unchanged element.

  • NOP : no operation. disable individual nuts temporarily - use for debugging only.

  • Sleep : pause processing thread for a given time.

  • Square : return square of element.

Processors : operate on iterables and return iterables

>>> [1, 2, 3, 4] >> Take(2) >> Collect()
[1, 2]
  • Append : append to the elements of the iterable.

  • Cache : caches elements on disk.

  • Chunk : split iterable in chunks of size n.

  • ChunkWhen : create new chunk whenever predicate function is true.

  • ChunkBy : create new chunk whenever function value changes.

  • Clone : clone elements in iterables n times.

  • Combine : combines elements in subsequences of length r.

  • Concat : concatenates iterables.

  • Cycle : cycle through elments of input iterable infinitely.

  • Dedupe : removes duplicates from iterable.

  • Drop : drops first n elements.

  • DropWhile : drops first elements while predicate function is true.

  • Filter : drops elements if predicate function is false.

  • FilterCol : extract given columns and drops elements if predicate function is false.

  • FilterFalse : drops elements if predicate function is true.

  • FlatMap : maps function on elements and flattens result.

  • Flatten : flattens iterables within the input iterable.

  • FlattenCol : extract given columns from (indexable) elements and flattens result.

  • GroupBy : groups elements based on grouping function.

  • GroupBySorted : groups presorted iterable of elements.

  • If : executes nut depending on condition.

  • Insert : insert into the elements of the iterable.

  • Interleave : interleaves elements of multiple iterables.

  • Map : maps function on elements.

  • MapCol : maps function on specific columns of (indexable) elements.

  • MapMulti : maps multiple functions on elements, resulting in multiple output iterators.

  • MapPar : map function (in concurrent threads) on elements.

  • Partition : split iterable into two partitions based on predicate function.

  • Permutate : return successive r length permutations of elements.

  • Pick : pick every n-th element or sample with given probability from iterable.

  • Prefetch : pre-fetch elements in separate thread.

  • Shuffle : shuffle elements (partially).

  • Slice : return slice of iterable.

  • Take : return first n elements.

  • TakeWhile : return elements while predicate function is true.

  • Tee : return n independent iterators over iterable.

  • Try : handle exceptions.

  • Window : return sliding window over elements of iterable.

  • Zip : zip elements from multiple iterables.

  • ZipWith : zips elements from multiple iterables with a given function.