Pandas provides the quantile
method to compute the quantiles of a Series or DataFrame. The quantile
method takes a single argument that specifies the quantile to compute as a decimal (e.g., 0.5 for the median, 0.25 for the first quartile). Here's an example:
main.py431 chars18 lines
This example creates a DataFrame with a single column, col1
, and then computes the median, first quartile, and third quartile of that column using the quantile
method. The results are printed to the console.
gistlibby LogSnag