Skip to content
Advertisement

New line character not being replaced even after trying many methods

I cannot get this to replicate outside of this file, since if I try it on a string myself it works, but for some reason not in my dataframe.

I just want to get rid of the ‘n’ characters in my strings, but its not working, as seen below.

enter image description here

I’ve tried the following, with no success

UseCaseMethodsCols.apply(lambda x: ' ' if 'n' in x else x)
UseCaseMethodsCols = UseCaseMethodsCols.replace(r'n', ' ').replace(r'r', '')

Advertisement

Answer

Try adding regex=True to the replace calls:

UseCaseMethodsCols = UseCaseMethodsCols.replace(r'n', ' ', regex=True)
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement