Questions tagged [toolz]

Toolz is a python package that provides a suite of composable, pure and lazy functions that make it easy to work in a functional style.

Toolz is a python package that provides a suite of composable, pure and lazy functions that make it easy to work in a functional style.

See also:

23 questions
0
votes
3 answers

How to write this python snippet in functional programming style?

How can I write the line below in functional python using e.g. toolz? dct1 = {1: 1, 2: 2} dct2 = {2:2} dct3 = {2:2, 3:3} common_keys = set(dct1.keys()) & set(dct2.keys()) & set(dct3.keys())
gebbissimo
  • 2,137
  • 2
  • 25
  • 35
0
votes
1 answer

import toolz results in an AttributeError during dask import

The python command import dask Results in a long error chain to one of its dependencies. I can replicate deeper parts of this error chain by importing tlz. import tlz Traceback (most recent call last): File "", line 1, in File…
Isaacnfairplay
  • 217
  • 2
  • 18
0
votes
2 answers

Using toolz.pipe with methods

I have a string that I want to clean using pipe from toolz. But it seems I can't figure out how to apply the str.replace method in the pipeline. Here is an example: x = '9\xa0766' from toolz import pipe import unidecode # Can do like this, but…
Retko
  • 332
  • 1
  • 5
  • 14
0
votes
1 answer

Using reduce with initial value in a Pipe with toolz Python

I am looking to perform a reduce operation as part of a pipe to sort dict items based on a key. e.g. from toolz import pipe items = [{"id":1, "val":1}, {"id":2, "val":2}, {"id":2, "val":3}] res = pipe(items, reduce(combine_items), other_ops...) #…
monsia
  • 23
  • 5
0
votes
1 answer

Does Dask/Pandas support removing rows in a group based on complex conditions that rely on other rows?

I'm processing a bunch of text-based records in csv format using Dask, which I am learning to use to work around too large to fit in memory problems, and I'm trying to filter records within groups that best match a complicated criteria. The best…
Denis de Bernardy
  • 75,850
  • 13
  • 131
  • 154
0
votes
1 answer

Composition of multiple functions onto one, each at a certain keyword

I have three functions: def addition(a: int, b: int): return a + b def increment(x: float) -> int: return int(x) + 1 def decrement(y: int) -> int: return x - 1 I would like to compose increment and decrement on top of addition to get a…
Uri
  • 25,622
  • 10
  • 45
  • 72
0
votes
2 answers

How to make a curry version of map that always returns list using toolz

If I import toolz using from toolz.curried import * then map will automatically becomes curried form, so map(func,[[1,2],[3,4]]) can be written as map(func)([[1,2],[3,4]]) but curried map always return an iterable. I way to define an curried…
user15964
  • 2,507
  • 2
  • 31
  • 57
-2
votes
1 answer

How to pass "extra" parameter to compose function

I' am searching for a way to compose function with an option to pass 'extra' parameter. Example: from toolz import compose_left def g(a, b, c) -> int: return a + b + c def f(a, b = 100) -> int: return a + b when i do…
Kees
  • 125
  • 2
  • 8
1
2