title: How does pandas calculate quartiles?
body: <p>I have a very simple dataframe:</p>
  
  <pre><code>df = pd.DataFrame([5,7,10,15,19,21,21,22,22,23,23,23,23,23,24,24,24,24,25], columns=['val'])
  </code></pre>
  
  <p>df.median() = 23 which is right because from 19 values in the list, 23 is 10th value (9 values before 23, and 9 values after 23)</p>
  
  <p>I tried to calculate 1st and 3rt quartile as:</p>
  
  <pre><code>df.quantile([.25, .75])
  
           val
  0.25    20.0
  0.75    23.5
  </code></pre>
  
  <p>I would have expected that from 9 values bellow median that 1st quartile should be 19, but as you can see above, python says it is 20.
  Similarly, for 3rd quartile, fifth number from right to left is 24, but python shows 23.5.</p>
  
  <p>How does pandas calculates quartile?</p>
  
  <p>Original question is from the following link:
  <a href="https://www.khanacademy.org/math/statistics-probability/summarizing-quantitative-data/box-whisker-plots/a/identifying-outliers-iqr-rule" rel="nofollow noreferrer">https://www.khanacademy.org/math/statistics-probability/summarizing-quantitative-data/box-whisker-plots/a/identifying-outliers-iqr-rule</a></p>