title: Removing outliers using percentile in panda dataframe groupby
body: <p>I have dataframe df</p>
  
  <pre><code>Transportation_Mode time_delta  trip_id segmentid   Vincenty_distance   velocity       acceleration       jerk
           walk           1          1        1          1.551676553     1.551676553     0.550163852    -1.017629555
           walk           1          1        1          1.70920675      1.70920675      0.16257622     -0.39166534
           walk           1          1        1          1.871782971     1.871782971    -0.22908912     -0.734438511
           walk          12          1        1          23.16466284     1.93038857      0.324972586    -0.331839143
           walk           1          1        1          5.830059603     5.830059603    -3.657097132     2.614438854
           bus            1         16        5          8.418372046     8.418372046    -7.259019484     7.40735053
           bus           23         16        5          26.66510892     1.159352562     0.148331046    -0.036318522
           bus            1         16        5          4.570966614     4.570966614    -0.68699497     -0.889126918
  </code></pre>
  
  <p>I want to remove outlier values within each group of Transportation_Mode based on percentile values [0.05,0.95]</p>
  
  <p>My problem is similar to discussion <a href="https://stackoverflow.com/questions/47104072/remove-outliers-in-pandas-dataframe-with-groupby">Remove outliers in Pandas dataframe with groupby</a></p>
  
  <p>The code I write is </p>
  
  <pre><code>res = df.groupby("Transportation_Mode")["Vincenty_distance"].quantile([0.05, 0.95]).unstack(level=1)
  df.loc[ (res.loc[ df.Transportation_Mode, 0.05] &lt; df.Vincenty_distance.values) &amp; (df.Vincenty_distance.values &lt; res.loc[df.Transportation_Mode, 0.95]) ]
  </code></pre>
  
  <p>but I get the error, ValueError: cannot reindex from a duplicate axis. I don't know where I am wrong here. </p>
  
  <p>Complete input data is available at the link <a href="https://drive.google.com/file/d/1JjvS7igTmrtLA4E5Rs5D6tsdAXqzpYqX/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1JjvS7igTmrtLA4E5Rs5D6tsdAXqzpYqX/view?usp=sharing</a></p>