I come from R and we love pipes, it makes really easier to understand the code and I try to apply it as mucha s I can. However, I'm trying to create a function that do many operations in a string. They work individually but when I try to set them as a chain into the function, they do not work:
def funtest(df, x):
(
df
.replace({x: {'ä': 'ae', 'ö': 'oe', 'ü': 'ue', 'β': 'ss'}}, regex = True, inplace = True)
.replace({x: '\s{2,}'}, ' ')
.replace({x: '^\s+'}, ' ')
.replace({x: '\s+$'}, ' ')
)
return df
funteste(df, 'strings')
Can anyone show me how I solve this?
