title: Remove '\n' in text in pandas python
body: <p>The following code is current code that i use to remove \n in ['text'] column:</p>
  
  <pre class="lang-py prettyprint-override"><code>df = pd.read_csv('file1.csv')
  
  df['text'].replace('\s+', ' ', regex=True, inplace=True) # remove extra whitespace
  df['text'].replace('\n',' ', regex=True) # remove \n in text
  
  header = ["text", "word_length", "author"]
  
  df_out = df.to_csv('sn_file1.csv', columns = header, sep=',', encoding='utf-8')
  </code></pre>
  
  <p>I've tried too from the suggestions:</p>
  
  <pre><code>df['text'].replace('\n', '')
  df['text'] = df['text'].str.replace('\n', '').str.replace('\s+', ' ').str.strip()
  </code></pre>
  
  <blockquote>
    <p>Output: ' What a smartass! \nLike he knows anything about real estate deals too...'</p>
  </blockquote>
  
  <p>The code to remove whitespace is working. But not in removing the \n. Anyone can help me on this matter? Thanks.</p>
  
  <p>I've tried to solve based on the suggestion from this link too <a href="https://stackoverflow.com/questions/44227748/removing-newlines-from-messy-strings-in-pandas-dataframe-cells">removing newlines from messy strings in pandas dataframe cells?</a> but it's still not working. </p>
  
  <p>Solved:</p>
  
  <pre><code>df['text'].replace(r'\s+|\\n', ' ', regex=True, inplace=True) 
  </code></pre>