Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How Quantile calculate
#1
Given below is source code for Pandas dataframe :
import pandas as pd
diSales= { 2016:{'qtr1':34500,'qtr2':56000,'qtr3':47000,'qtr4':49000},
           2017:{'qtr1':44900,'qtr2':46100,'qtr3':57000,'qtr4':59000},
           2018:{'qtr1':54500,'qtr2':51000,'qtr3':57000,'qtr4':58500},
           2019:{'qtr1':61000}
         }
ks = pd.DataFrame(diSales)
ptr = ks.quantile([0.25,0.5,0.75,1.0])
print(ptr)
Output:
Output:
2016 2017 2018 2019 0.25 43875.0 45800.0 53625.0 61000.0 0.50 48000.0 51550.0 55750.0 61000.0 0.75 50750.0 57500.0 57375.0 61000.0 1.00 56000.0 59000.0 58500.0 61000.0


What will be the mathematical formula/calculation for quantile ? How this output comes i don't know so please expalin with simple math calculation here ..
Reply
#2
pandas.DataFrame.quantile
https://en.wikipedia.org/wiki/Quantile
Reply
#3
(Jul-04-2019, 05:13 AM)ThomasL Wrote: pandas.DataFrame.quantile
https://en.wikipedia.org/wiki/Quantile

anybody can explain how we can calculate first quartile value of column "2016" for row "0.25" and its value is 43875.0 ? Actually mathematically its value is wrong and correct value is 40750...please correct me if i am wrong ?

Now problem has been resolved. i used interpolation as midpoint.

interpolation : {‘linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’}
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020