We have a character | in one of the columns in a pandas dataframe which needs to be replaced with a new line within the same columns.
I tried using replace which doesn't seem to give the expected output.
import pandas as pd
df = pd.DataFrame(['sample || text | needs replacement'] , columns=['text'])
df.text.str.replace('|' , '\n')
# Gives sample \n\n text \n needs replacement
# Expected output
"""sample
text
needs replacement
"""
print(len(df['text'])) #1