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 don't want to use nesting.
int(unidecode.unidecode(x).replace(" ", ""))
# Wan't to try to do like this, with sequence of steps, applying transformations on previous output.
pipe(x,
unidecode.unidecode,
replace(" ", ""),
int
) # DON'T WORK!!
# NameError: name 'replace' is not defined
More generally, notice that the output of unidecode.unidecode
is a string. So I want to be able to apply some string methods to it.
pipe(x,
unidecode.unidecode,
type
) # str
Is it possible with pipe?