I have a similar problem to the one posted here:
Pandas DataFrame: remove unwanted parts from strings in a column
I need to remove newline characters from w
You could use regex
parameter of replace
method to achieve that:
misc['product_desc'] = misc['product_desc'].replace(to_replace='\n', value='', regex=True)
strip
only removes the specified characters at the beginning and end of the string. If you want to remove all \n
, you need to use replace
.
misc['product_desc'] = misc['product_desc'].str.replace('\n', '')