title: Python Pandas Removing outliers vs Nan outliers
body: <p>I'm trying to understand why this happens in the data frame</p>
  <pre><code>import pandas as pd 
  import numpy as np
  #from pyspark.sql import SparkSession
  
  #spark = SparkSession.builder.getOrCreate()
  
  df = pd.DataFrame({&quot;calories&quot;: [400, 200, 220, 70000, 500, 200, 300, 200, 100, 100, 100, 200, 300, 100, 200, 300, 400, 500, 100]})
  
  q_low = df[&quot;calories&quot;].quantile(0.01)
  q_hi = df[&quot;calories&quot;].quantile(0.99)
  lb = df.quantile(0.01)
  ub = df.quantile(0.99)
  
  #replaces outliers with nan
  df_filtered = df[(df &lt; ub) &amp; (df &gt; lb)]
  
  #removes outliers
  df_filtered = df[(df[&quot;calories&quot;] &lt; q_hi) &amp; (df[&quot;calories&quot;] &gt; q_low)]
  print(df_filtered)
  </code></pre>
  <p>The first df_filtered will set all outliers to NaN, while the second df_filtered will remove all outliers. What is the functional difference between these two operations? Why does the first one set the outliers to NaN, and the second one just remove them?</p>